I\'m sure this is a no-brainer when you\'re into shell programming. Unfortunately I\'m not and I\'m having a pretty hard time ...
I need to verify arguments passed t
There is no method to access next argument in for.
How about to rewriting your script to use getopt?
If you don't like getopt, try to rewrite your script using shift:
while [ -n "$1" ]
do
str="$1"
minus=${str:0:1}
if [ "$str" == "-o" ]
then
shift
par="$1"
# ...
elif [ "$minus" == "-" ]
then
# append element into array
myArray[${#myArray[@]}]="$str"
fi
shift
done
In bash, you can use indirect parameter expansion to access an arbitrary positional parameter.
$ set a b c
$ paramIndex=2
$ echo $2
b
$ echo ${!paramIndex}
b