[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: builtins/getopt.c is broken. last working one was 2.05a

From: Christos Zoulas
Subject: RE: builtins/getopt.c is broken. last working one was 2.05a
Date: Mon, 7 Apr 2003 12:41:22 -0400


This is quite annoying because it is a behavior change that is
not easy to detect. Pdksh behaves the same way too [like bash
used to and ash does]. It is not even easy to find the name of
the option that failed since now it turned into '?'. I don't
understand the rationale of this change, since it was easier to
have getopts give up on the first unrecognized option and have
another program to process the rest of the options, but now, I 
cannot even find the name of the option that was not recognized.

What do you think? Should we ask David Korn on why this was changed?


> -----Original Message-----
> From: Chet Ramey [mailto:address@hidden 
> Sent: Monday, April 07, 2003 9:28 AM
> To: Christos Zoulas
> Cc: address@hidden; address@hidden
> Subject: Re: builtins/getopt.c is broken. last working one was 2.05a
> > Machine Type: i686-pc-linux-gnu
> > 
> > Bash Version: 2.05b
> > Patch Level: 0
> > Release Status: release
> > 
> > Description:
> > 
> >     $OPTIND gets incremented on unmatched option.
> I believe that this is the correct behavior, according to 
> POSIX.2.  getopts returns the option, even though it's not 
> one of the recognized ones, because it's of the correct form.
> POSIX.2 says:
> Each time it is invoked, the getopts utility shall place the 
> value of the next option in the shell variable specified by 
> the name operand and the index of the next argument to be 
> processed in the shell variable OPTIND.
> Since getopts returns the unrecognized option (after a 
> fashion; it sets its `name' argument to `?'), and doesn't 
> consider it an error, it should increment OPTIND.
> ksh93 behaves the same way, but the BSD sh does not.
> Chet
> -- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ( ``Discere est Dolere'' -- chet )
> Chet Ramey, ITS, CWRU    address@hidden    
> http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]