* new getopt features committed
@ 2014-12-11 3:31 Rich Felker
0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2014-12-11 3:31 UTC (permalink / raw)
To: musl
I've just committed support for options after non-option arguments
("argv permutation" ala GNU getopt) in getopt_long only (same way it
works on BSD -- plain getopt is always POSIX conforming but
getopt_long has the new feature) and abbreviated long options.
Hopefully this eliminates the need to patch libc (like Alpine is doing
up til now) or individual apps (like some other dists are doing) with
an alternate getopt implementation.
A couple differences from GNU and BSD variants:
- The code in musl now does not honor $POSIXLY_CORRECT. The only way
to suppress argv permutation in getopt_long is with a leading '+' in
the optstring. This may be changed depending on feedback.
- The progression of optind is different, and IMO much less
counter-intuitive, when options after non-option arguments are being
processed. But the final argv[] order and final optind after
getopt_long returns -1 should be the same.
- No additional internal state is kept for non-option argument
skipping. As a result, more passes over argv[] are needed in some
cases, but it shouldn't make a practical performance difference.
- Reporting of errors may be different; this is unintentional and
should be fixed. In particular getopt_long does not print any
messages for long option errors; only short options (handled by
getopt internally) produce messages. Return values may be different
too.
If there are any regressions, let me know.
Rich
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-12-11 3:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 3:31 new getopt features committed Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).