Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150118181459.GD4574@brightrain.aerifal.cx>
Date: Sun, 18 Jan 2015 13:14:59 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: getopt_long_only and slightly unambiguous options

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.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.