How can I pass a quoted string as a single argument via bash variable How can I pass a quoted string as a single argument via bash variable shell shell

How can I pass a quoted string as a single argument via bash variable


An array will take care of all the quoting issues.

[env.sh] options=(-def "hello world")[run.sh]source ./env.sh myprogram "${options[@]}"

export keyword removed since it is unnecessary here and also doesn't work for arrays.


You can do this without changing env.sh:

IFS=$'"'opt=($options)myprogram "${opt[@]}"