I need to pass some text that includes whitespace and other characters to a script that's being run by GNU Parallel.
Here is a very simple example:
$ seq 1 3 | parallel echo "Quoted ' (text)"
The above example will output this:
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
However, if I do this everything works:
seq 1 3 | parallel echo "\"Quoted ' (text)\""
I happen to be running this from a python script, so before passing the arguments I'm double quoting them in the script like this:
args = ["Some arg", "Another arg", "etc."]
args = ' '.join(pipes.quote(pipes.quote(arg)) for arg in args)
But it doesn't seem like a clean solution.
Does anybody know of a better way to pass arguments to GNU Parallel?
Thanks!