Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Wed, 29 May 2002 15:33:19 -0700 (Pacific Daylight Time) From: Michael A Chase Subject: Re: trivial mkpasswd defect To: Bernard A Badger , cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-Disposition: INLINE References: In-Reply-To: Reply-To: Michael A Chase Message-Id: On Wed, 29 May 2002 17:45:35 -0400 Bernard A Badger wrote: > > -----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 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 ;-) I don't see anything there that says that POSIX endorses '-?' for displaying the usage message. It just shows how to handle invalid option characters. If getopt sees an invalid character after '-' it returns '?' and puts the invalid character ("?" in your example) in optopt. In that example, I'd expect to see Unrecognized option -? <> From 'man bash': getopts optstring name [args] getopts is used by shell procedures to parse positional parameters. optstring contains the option characters to be recognized; if a character is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. The colon and question mark characters may not be used as option characters. . . . I don't have the man page for getopt() handy, but I think it contains the same restriction. -- Mac :}) ** I normally forward private questions to the appropriate mail list. ** Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age. -- 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/