ok, from the top
assume parameters: "a b" "c" "d e"
when you do something like this:
bash does this:
Code:
Arguments=a b c d e
any information about what constitutes a single entity is lost. Storing all params in a single variable can NEVER work properly if you can stumble upon any whitespace. In other words: don't do it.
Code:
/usr/bin/env python "${PYTHON_LAUNCHER_MAIN}" ${Arguments}
is equal to
Code:
/usr/bin/env python ... a b c d e
quoting that variable ("${Arguments}") won't work, bash would see this:
Code:
/usr/bin/env python ... "a b c d e"
as i said, original information about parameters is destroyed
now, if you want to pass parameters through without any change you have two options
1. call all parameters directly (preparation line not needed)
Code:
/usr/bin/env python "${PYTHON_LAUNCHER_MAIN}" "$@"
which is equal to
Code:
/usr/bin/env python ... "a b" "c" "d e"
2. use array
Code:
Arguments=( "$@" ) # Arguments=( "a b" "c" "d e" )
/usr/bin/env python "${PYTHON_LAUNCHER_MAIN}" "${Arguments[@]}"
which is equal to
Code:
/usr/bin/env python ... "a b" "c" "d e"
array approach is potentially more flexible because you can do nifty things like this with the array:
Code:
Arguments=( "x" "y" "$@" "z" ) # args=( "x" "y" "a b" "c" "d e" "z" )
Arguments+=( "111" "222" ) # args=( "x" "y" "a b" "c" "d e" "z" "111" "222" )
...
/usr/bin/env python ... "${Arguments[@]}"
=
/usr/bin/env python ... "x" "y" "a b" "c" "d e" "z" "111" "222"
quoting these "$@" and "${array[@]}" is crucial though, without it parameters will break down to pieces, just like they do in your current scenario. I showcased it in my earlier post, with red color marking the results of such a negligence and blue color marking the proper solutions.
If you don't know bash' in-and-outs well, go with the following rule of thumb: "no variable is left unquoted"
Bookmarks