I need to process command line options in several passes using getopts.
During getopts processing, I also need to use shift $(($OPTIND)), resulting
in changes to $@.
I would like to save a copy of "$@" and reset it using 'set' command but
cannnot figure out any way to inhibit evaluation of arguments to set.
Here is my code and results.
Thanks for any ideas.
--- FILE: test
#!/usr/local/bin/bash
echo num params=$#
saved="$@"
echo 'set -- "$@"'
set -- "$@"
echo num params=$#
echo 'set -- "$saved"'
set -- "$saved"
echo num params=$#
echo 'set -- $saved'
set -- $saved
echo num params=$#
---- OUTPUT:
[greg@p3 junk]$ ./test 'hi there' greg
num params=2
set -- "$@"
num params=2
set -- "$saved"
num params=1
set -- $saved
num params=3
- Greg Keraunen
http://www.xmake.org