home *** CD-ROM | disk | FTP | other *** search
- From mlandau@Diamond.BBN.COM Fri Aug 29 15:21:54 1986
- Received: by mirror.TMC.COM (4.12/UUCP-Project/rel-1.0/08-20-86)
- id AA09715; Fri, 29 Aug 86 15:21:48 edt
- Received: by Diamond.BBN.COM; Fri, 29 Aug 86 14:20:15 EDT
- Date: Fri, 29 Aug 86 14:20:15 EDT
- From: Matt Landau <mlandau@Diamond.BBN.COM>
- Message-Id: <8608291820.AA02073@Diamond.BBN.COM>
- To: mirror!rs
- Subject: Getopt(1) from mod.sources
- Status: R
-
- Rich -
-
- Your /bin/sh example doesn't work on the Sun 3.0 /bin/sh,
- which is derived from SysV Rel2. Besides the obvious error (getopt
- asking about flags "d:s" and then checking for -a and -b in the
- body), there are a few other problems. Here's the corrected version
- for merging back into the man page (assuming it was globally wrong
- and that this isn't due to our shell):
-
- #!/bin/sh
- set -- `getopt "ab:" $@`
- if test $? != 0 ; then
- echo "Read the documentation and try again."
- exit 1
- fi
- Aflag=0
- Name=NONE
- for f
- do
- case "$f" in
- -a) Aflag=1
- ;;
- -b) shift
- Name=$1
- ;;
- --) break
- ;;
- esac
- shift
- done
- echo Aflag=$Aflag / Name=$Name / Remaining args are $*
-
-