[1122] in RedHat Linux List

home help back first fref pref prev next nref lref last post

bug in bash?

daemon@ATHENA.MIT.EDU (Julien Maillard)
Sat Oct 26 15:34:23 1996

To: redhat-list@redhat.com
Reply-To: maillard@vt.edu
Date: Sat, 26 Oct 1996 15:31:05 -0400
From: Julien Maillard <maillard@tulipe.val.org>
Resent-From: redhat-list@redhat.com

I have the bash script:
--
#!/bin/bash
while getopts :p: arg
do
  echo "arg=$arg OPTARG=$OPTARG"
  case $arg in
  p) echo "p option called arg=$OPTARG"  ;;
  :) echo "$0: Must supply an argument to $OPTARG." ;;
  \?) echo "Invalid option $OPTARG ignored." >&2 ;;
  esac
done
--
which gives me:
--
[maillard@tulipe maillard]$ test0 -p 12
arg=p OPTARG=12
p option called arg=12
-- this is ok

[maillard@tulipe maillard]$ test0 -x
arg=? OPTARG=x
Invalid option x ignored.
-- this is ok

[maillard@tulipe maillard]$ test0 -p
arg=? OPTARG=p
Invalid option p ignored.
-- this is not OK! the missing argument should cause getopts to set arg to 
colon (:), right? that's what the man page says...

Can anyone tell me what's wrong here? Thank you.

-- 
Julien Maillard                                       maillard@vt.edu
Virginia Tech
                tel: (540) 231 4285,  fax: (540) 231 8836



--
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
  ________________________________________________________________________
  http://www.redhat.com/RedHat-FAQ   http://www.redhat.com/RedHat-Errata
  http://www.redhat.com/RedHat-Tips  http://www.redhat.com/mailing-lists
  ------------------------------------------------------------------------
To unsubscribe: mail -s unsubscribe redhat-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post