I currently have a bash script where I want to separate the command to be executed from the execution itself (for readability purposes):
set -x
MAIN_COMMAND="mysql -u root \"select 1 from dual;\""
...
MAIN_RESULT=$($MAIN_COMMAND 2>&1)
when executing the command, I get the following debug output:
++mysql -u root '"select' 1 from 'dual;"'
obviously, there's something wrong with the way I escaped the string, but I can't pinpoint it.
furthermore the output redirection does not get concatenated to the main command.