Suppose I have an executable xyz that takes a variable number of command-line arguments, and a wrapper Korn shell script xyz.ksh. Is there an easy way to pass all of the shell script arguments as-is to the executable?
Tell me more
×
Server Fault is a question and answer site for
professional system and network administrators. It's 100% free, no registration required.
|
You need to use:
for correct parameter expansion in all cases. This behaviour is the same in both bash and ksh. Most of the time, $* or $@ will give you what you want. However, they expand parameters with spaces in it. "$*" gives you all parameters reduced down to one. "$@" gives you what was actually passed to the wrapper script. See for yourself (again, under either bash or ksh):
|
|||
|
|
|
I think you're looking for the $* variable: http://www.well.ox.ac.uk/~johnb/comp/unix/ksh.html#commandlineargs It's otherwise known as $@ in bash, I think. |
|||||
|
|
Yes. Use the $* variable. Try this script:
and then invoke the script with something like:
Your output will be:
|
|||
|
|