delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/29/17:45:46

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Bernard A Badger" <bab AT vx DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: trivial mkpasswd defect
Date: Wed, 29 May 2002 17:45:35 -0400
Message-ID: <INEKLKBFCDBPKMKAJLMDGEJGCDAA.bab@vx.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
In-Reply-To: <E17D8tc-0001wt-00@maynard.mail.mindspring.net>
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700


> -----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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019