From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6868 Path: news.gmane.org!not-for-mail From: Felix Janda Newsgroups: gmane.linux.lib.musl.general Subject: Re: getopt_long_only and slightly unambiguous options Date: Sun, 18 Jan 2015 19:27:23 +0100 Message-ID: <20150118182723.GA24143@euler> References: <20150118175159.GA4901@euler> <20150118181459.GD4574@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1421605728 15152 80.91.229.3 (18 Jan 2015 18:28:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Jan 2015 18:28:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6881-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jan 18 19:28:48 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YCuae-0001AN-3D for gllmg-musl@m.gmane.org; Sun, 18 Jan 2015 19:28:48 +0100 Original-Received: (qmail 8058 invoked by uid 550); 18 Jan 2015 18:28:46 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 8050 invoked from network); 18 Jan 2015 18:28:46 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20150118181459.GD4574@brightrain.aerifal.cx> User-Agent: Mutt/1.5.22 (2013-10-16) Xref: news.gmane.org gmane.linux.lib.musl.general:6868 Archived-At: Rich Felker wrote: > On Sun, Jan 18, 2015 at 06:51:59PM +0100, Felix Janda wrote: > > Hello, > > > > since widl from wine uses the combination, get_opt_long_only seems to > > be supposed to be able to differentiate between a short option "-h" > > and a long option "--help". Together with the possibility of option > > abbreviations, the behavior we are trying to copy is: > > > > -h -> -h > > --help -> --help > > -help -> --help > > -he -> --help > > --h -> --help > > > > However musl maps all of them to --help. > > > > The man page is ambiguous about this aspect and I'm not sure if the > > BSDs have the same behavior here. (However I would suspect that the > > breakage in widl, when the --help option was added in 2012, would > > have been noticed.) As always, it is hard to measure how many > > applications (and scripts written against these applications) might > > depend on this behavior. Since getopt_long_only is discouraged > > maybe these are actually quite few, though. > > > > All in all I think that this a bug in musl which should be fixed. > > > > > > For the implementation, is it maybe enough in __getopt_long_core to > > pass options starting with '-' and of exactly two characters > > directly to getopt? > > I would think getopt_long_only would even want to treat "-he" as "-h" > and "-e", i.e. abbreviations should be suppressed entirely when only a > single leading "-" appears instead of "--". However I'd rather follow > historical practice unless it's something stupid and complex (and > violating the principle of least surprise for users) like checking > whether each char is a valid short option and basing the decision on > that. I've just checked that even when there are both -h and -e short options glibc getopt_long_only treats -he as --help. Felix