Bash Arguments Problem
by Linunix from LinuxQuestions.org on (#6MDDM)
Hello
Encountered a problem concerning script arguments in bash (likely also sh). Arguments to a call of a script get unboxed in the sense that surrounding quotation characters '"' are removed in the values you can use inside of the script, namely as $1, $2 $* etc. These quotations are used e.g. when an argument contains blank characters. So far so good, but if you need to pass some or all script arguments on to some other program call inside the script, what will you do?
If you don't know the exact number of arguments, you would be inclined to use "$*" as single argument to Z (your inside program call). But this loses the brackets '"' and the call fails due to incorrect argument transmission. You can use "$1" "$2" "$3" etc. as arguments to Z but this fixes the number of arguments, which is not always a tolerable error.
What is in demand is a way to transmit the original arguments to a script on to a subprogram. I have not found such a way. Anybody has a solution?
Encountered a problem concerning script arguments in bash (likely also sh). Arguments to a call of a script get unboxed in the sense that surrounding quotation characters '"' are removed in the values you can use inside of the script, namely as $1, $2 $* etc. These quotations are used e.g. when an argument contains blank characters. So far so good, but if you need to pass some or all script arguments on to some other program call inside the script, what will you do?
If you don't know the exact number of arguments, you would be inclined to use "$*" as single argument to Z (your inside program call). But this loses the brackets '"' and the call fails due to incorrect argument transmission. You can use "$1" "$2" "$3" etc. as arguments to Z but this fixes the number of arguments, which is not always a tolerable error.
What is in demand is a way to transmit the original arguments to a script on to a subprogram. I have not found such a way. Anybody has a solution?