From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: new getopt features committed
Date: Wed, 10 Dec 2014 22:31:03 -0500 [thread overview]
Message-ID: <20141211033103.GA8429@brightrain.aerifal.cx> (raw)
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
reply other threads:[~2014-12-11 3:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141211033103.GA8429@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).