I'm writing a Bash script in which I am running a perl script which requires flags that have double quotes in them. Running the script normally, you would run
$ perl script.pl -flag="something" -anotherflag="somethingelse"
In my script, I'm using variables in these flags, but would like to preserve the doublequotes, so I have something like:
variable=foo
perl script.pl -flag=\"something\" -anotherflag=\"$variable\"
when i run bash -x myscript.sh
, I see that it adds single quotes around the entire flag, while maintaining the doublequotes, causing the perl script to error:
perl script.pl '-flag="something"' '-anotherflag="foo"'
I also tried eval
ing the whole thing (eval perl [...]
), and it stripped out the doublequotes altogether. How can I have Bash run the script with the doublequotes intact?