Subject: 1.4.1 sh's backquoted getopts doesn't work
To: None <netbsd-help@netbsd.org>
From: Erich T. Enke <Erich.T.Enke@wheaton.edu>
List: netbsd-help
Date: 02/03/2000 13:59:19
Subject pretty much says it. In 1.3.3, `getopts ab:c var` works as
expected, but in 1.4.1, getopts ab:c var works whereas `getopts ab:c var`
doesn't. Also, it might be nice to have a search engine on
http://www.netbsd.org/MailingLists to allow just searching the mailing
list archives. I haven't had the best luck trying to do so off of the
main search engine, and thereby don't have any way that I know of to
know whether this question has already been handled. An example script
on 1.4.1 follows:
Script started on Thu Feb 3 13:48:35 2000
Thu Feb 3 13:48:36
[1] eenke@scilab13:ttyp3:/scilab/laac/bin:$ getopts_example.tmp -a -b word
Before first getopts
OPTIND: 1
OPTARG:
VAR:
After first unbackquoted getopts
OPTIND: 2
OPTARG:
retval: 0
VAR: a
After second backquoted getopts
OPTIND: 2
OPTARG:
retval: 0
VAR: a
After third unbackquoted getopts
OPTIND: 4
OPTARG: word
retval: 0
VAR: b
**************************************
the shell script follows for reference:
**************************************
Thu Feb 3 13:48:54
[2] eenke@scilab13:ttyp3:/scilab/laac/bin:$ cat getopts_example.tmp
#!/bin/sh
echo "Before first getopts"
echo "OPTIND: $OPTIND"
echo "OPTARG: $OPTARG"
echo "VAR: $var"
getopts ab:c var
retval=$?
echo ""
echo "After first unbackquoted getopts"
echo "OPTIND: $OPTIND"
echo "OPTARG: $OPTARG"
echo "retval: $retval"
echo "VAR: $var"
`getopts ab:c var`
retval=$?
echo ""
echo "After second backquoted getopts"
echo "OPTIND: $OPTIND"
echo "OPTARG: $OPTARG"
echo "retval: $retval"
echo "VAR: $var"
getopts ab:c var
retval=$?
echo ""
echo "After third unbackquoted getopts"
echo "OPTIND: $OPTIND"
echo "OPTARG: $OPTARG"
echo "retval: $retval"
echo "VAR: $var"
Thu Feb 3 13:49:05
[3] eenke@scilab13:ttyp3:/scilab/laac/bin:$ exit
exit
Script done on Thu Feb 3 13:49:06 2000