I have the following
function doit() { echo "'$1', '$2', '$3'"; }
export -f doit
args=("a" "") # Empty argument
echo -e "1\n2" | parallel -k "doit" "${args[@]}" {}
Which does not forward the empty argument:
'a', '1', ''
'a', '2', ''
instead it should be
'a', '', '1'
'a', '', '2'
Why does parallel do this and how to fix it?
CodePudding user response:
parallel
passed strings to bash -c
- they are interpreted according to shell rules, empty arguments are just concatenated and subject to word splitting expansion.
If you want to preserve arguments, quote them. Either "$(printf "%q " "${args[@]}")"
manually or just parallel -q --quote
.