From: Maximillien Lincourt <max@toonboom.com>
Subject: Sh shell script problem on OSF4.0 (but not on SGI) (getopts and shift)
Date: 1997/05/21 [thread overview]
Message-ID: <33831D34.41C6@toonboom.com> (raw)
I'm trying to use the getopts argument parser in a sh shell script, on
DEC's OSF1 (4.0 and on SGI 6.x) but I seem to be having some soft of
problems using it. It seems that the getopts does not get called! is the
man page wrong or there's something I don't understand, could it be that
getopts path is wrong ?
There's also a problem with the shift command, is the syntax correct
with all the parentheses on the sh man page on SGI they use
shift `expr $OPTIND - 1`
instead of which does not work on DEC either
shift $(($OPTIND - 1))
I tried the exemple in the DEC's man pages which is (does not work on
DEC or SGI (getopts on DEC and shift on SGI):
aflag=
bflag=
while getopts ab: name
do
case $name in
a) aflag=1;;
b) bflag=1
bval="$OPTARG";;
?) printf "Usage: %s: [-a] [-b value] args\n" $0
exit 2;;
esac
done
if [ ! -z "$aflag" ]; then
printf "Option -a specified\n"
fi
if [ ! -z "$bflag" ]; then
printf 'Option -b "%s" specified\n' "$bval"
fi
shift $(($OPTIND - 1))
printf "Remaining arguments are: %s\n" "$*"
on SGI the example is (and it's working on SGI but not on DEC
(shift problem!)
while getopts abo: c
do
case $c in
a | b) FLAG=$c;;
o) OARG=$OPTARG;;
\?) echo $USAGE
exit 2;;
esac
done
shift `expr $OPTIND - 1`
Thanks for any help!
next reply other threads:[~1997-05-21 4:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-21 4:00 Maximillien Lincourt [this message]
1997-05-28 4:00 ` Sh shell script problem on OSF4.0 (but not on SGI) (getopts and shift) Bob Vickers
1997-05-28 4:00 ` Chet Ramey
1997-06-09 4:00 ` David Boyce
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox