Hi,
I am using getopts in a while loop for different options I have in a function:
Here have part of my code:
funct()
{
var1="N"
var2=''
while getopts ":b:c
ma" opt
do
case $opt in
b)body=$OPTARG;;
c)change=$OPTARG;l_INF="Y";;
p)..
m)..
a)...
\?)...
esac
done
}
and I am calling the function from other script .
when I am calling the function for the first time (in other script )
funct -b "<something>" -c "<something>" -a
the body variable in b)body=$OPTARG;; is populating correctly but afterwards whenever I am calling the funct
funct -b "<XXXX>" -c "YYYY" -a
the -b option is getting ignored by getopts and it is OK with other options.I tried changing the order of options ,it is also did't work.
What could be the possible reason?
I want some help on this getopts :
1) does it matter the order of options?
2) How the value of $OPTIND(option index) get assigned? I mean is it like in the order of calling in function or in the order in which it is defined in getopts
getopts ":b:c
ma" i.e. b has OPTIND=2,for c=3 or just it is just in any value>1?
Thanks :-)
its
=colon : then p