Hello - I have to modify an existing ksh script which looks at the command-line arguments using 'shift', and so empties $@, but now want to pass the original arguments to a second script afterwards.
In the mainline case I can do this by coping $@ to a variable and passing that to the second script, but I can't get it to work for quoted command-line arguments.
If I have a script called 'printer' like below:
#!/bin/ksh
INPUT=$@
echo "Printing args"
until [[ $# -eq 0 ]];do
echo $1
shift
done
./printer2 $INPUT
and printer2 like below:
#!/bin/ksh
echo "Printing second args"
until [[ $# -eq 0 ]];do
echo $1
shift
done
I would like the output of
./printer first second "third forth"
to be :
Printing args
first
second
third forth
Printing second args
first
second
third forth
I've tried various combinations of quotes around variables (both in the assignment of $INPUT and when passing it to printer2) but can't figure it out. Can anyone help?