Helpful hint, if you have a bash script with a function calling getopts, i.e.
make_tarball() {
local START=`get_start_time`
## declare some variables
.....
local OPTARG OPTIND
## Parse the args
while getopts "s:d:a:x:X:v" ARG
do
case $ARG in
s) SOURCE_PATH="$SOURCE_PATH $OPTARG"
;;
....
esac
done
you MUST make OPTIND a local variable, or a second (third, etc) call to the function will fail, with OPTIND too large to see any of the arguments
blegh
A
Leave a comment