ksh bug?

Guangliang He ghe at physics.orst.edu
Thu Nov 8 12:47:43 AEST 1990


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 at PHYSICS.ORST.EDU
                            Guangliang He

                            ghe at PHYSICS.ORST.EDU
                            hegl at ORSTVM.BITNET



More information about the Comp.unix.aix mailing list