Mail Archives: cygwin/2002/05/29/17:45:46
> -----Original Message-----
> From: Michael A Chase [mailto:mchase AT ix DOT netcom DOT com]
> To: Bernard A Badger; cygwin AT cygwin DOT com
> Subject: Re: trivial mkpasswd defect
> On Wed, 29 May 2002 12:27:15 -0400 Bernard A Badger <bab AT vx DOT com> wrote:
>
> > > -----Original Message-----
> > > On Wed, May 29, 2002 at 10:14:14AM -0400, Jon LaBadie wrote:
> > > > mkpasswd reports '?' is a valid help option but fails to accept it.
> > > > $ mkpasswd -?
> > > > mkpasswd: unknown option -- ?
> > >
> > > Thanks. This will go away in the next version.
> >
> > I hope you mean that '-?' will work, not that '-?' will be taken out of the
> > usage.
>
> In Unix envronments -h is more commonly used for help. '-?' as an option
> is subject to filename expansion which can lead to odd behavior if it isn't
> quoted.
Well, the example from man 2 getopt has this:
while ((c = getopt(argc, argv, ":abf:o:")) != -1) {
switch(c) {
....
case '?':
fprintf(stderr,
"Unrecognized option: -%c\n", optopt);
errflg++;
}
}
if (errflg) {
fprintf(stderr, "usage: . . . ");
exit(2);
Which exemplifies the custom of printing the "usage" upon an error.
Since '?' cannot be used as a getopt option, it is guaranteed to cause
getopt to return '?' no matter what the option characters are.
I saw this on a SGI Irix, and I checked at www.opengroup.org for the POSIX
standard.
Of course, if you're not following POSIX, and aren't using getopt, it may not
work. Your personal experience of '-h' being a "help" option, probably carries
less weight than the endorsement of POSIX ;-)
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -