Search code examples
bashnestedevalquotes

Bash nested quotes and eval


I'm having difficulty nested quotes within a bash script

argv="su -c '$RVM_PATH wrapper $config_rvm \'$PASSENGER_RVM_BIN $command $options\'' web"
eval $argv

The above got me

eval: line 162: unexpected EOF while looking for matching `''
eval: line 163: syntax error: unexpected end of file

Solution

  • argv="su -c \"$RVM_PATH wrapper $config_rvm \\\"$PASSENGER_RVM_BIN $command $options\\\"\" web"