I get some strange behavior when trying to pass script parameters along to an external program, in ksh.
My setup is like this :
– I have a ksh script (called “test”), that boils down to something like this :
...
args="$@"
java my_main_class $args
...
– If I call this script with something like :
> ./test "param1 param2" param3
…then the external application sees the following parameters : (param1, param2, param3)
-
If I change the script into something like :
... java my_main_class "$@" ...
…and do the same invocation, then my external application sees the following parameters (param1 param2, param3) – meaning that now, parameters are correctly seen.
Question : how can I modify my first version of the script, in order to correctly pass the parameters containing spaces, while still storing the “@$” into a variable, before external program invocation ?
Kind regards,
Andrei
First, let’s setup the same session:
param1 param2, param3ksh and bash offer a valid solution with an array assignment:
This will still fail without quoting:
param1param2param3But quotes and array combined make this work:
param1 param2param3