Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!ogicse!orstcs!physics.orst.edu!ghe From: ghe@physics.orst.edu (Guangliang He) Newsgroups: comp.unix.aix Subject: ksh bug? Message-ID: <21641@orstcs.CS.ORST.EDU> Date: 8 Nov 90 01:47:43 GMT Sender: usenet@orstcs.CS.ORST.EDU Reply-To: ghe@physics.orst.edu (Guangliang He) Organization: Dept. of Physics, OSU Lines: 47 I'm starting to learn ksh on a RS/6000 with AIX 3.1. I typed in a piece of script from 'The Korn Shell' by Morris I. Bolsky & David G. Korn. The output of the script is not what I would expect. The shell script is on page 216 of the book. Script started on Wed Nov 07 17:27:40 1990 1$ cat bug #!/bin/ksh while getopts :abo: c do case $c in a) aflag=1;; +a) aflag=;; b) bflag=1;; +b) bflag=;; o) oflag=$OPTARG;; :) print -u2 "$0: $OPTARG requires a value:" exit 2;; \?) print -u2 "$0: unknow option $OPTARG" exit 2;; esac done shift OPTIND-1 2$ bug 3$ bug -a 4$ bug -b 5$ bug -c ./bug: unknow option 6$ bug -o ./bug: requires a value: 7$ bug -o 1 8$ script done on Wed Nov 07 17:28:08 1990 Look at command number 5 and number 6. It seems that $OPTARG was not assigned even though the first argument after getopts begins with character ':'. This is different from what the book, and the man page on the AIX machine. Any one can come up with reasonable answer? Guangliang He ghe@PHYSICS.ORST.EDU Guangliang He ghe@PHYSICS.ORST.EDU hegl@ORSTVM.BITNET