I'm attempting to create this command and it fails because the desc variable is being interpreted separately instead of a quoted string. I've tried many variations of quoting with and without using single quotes to make text literal including the my latest attempt below.
If I call the function using:
new_proj "FALSE" "TRUE" "This is a test" "path" "to"
function
new_proj(){
[ "$1" = "FALSE" ] && local p="p"
[ "$2" = "TRUE" ] && local o="o"
local sw="$p$o"
[ ! -z $sw ] && sw="-$sw"
local desc="$3"
local account="$4"
local name="$5"
local create=$(echo mycmd "$sw" -d "desc" "account"/"name")
if $create; then
echo "created."
return 0
else
echo "failed!"
return 1
fi
}
Expected result - mycmd -po -d "This is a test" path/to
$(echo mycmd "$sw" -d \"desc\" "account"/"name")
– The Coding Penguin Jul 01 '19 at 15:17