mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] getopt: add support for non-option arguments
Date: Tue, 25 Nov 2014 02:39:32 -0500	[thread overview]
Message-ID: <20141125073932.GR29621@brightrain.aerifal.cx> (raw)
In-Reply-To: <20141125073350.GA8419@sottospazio.it>

On Tue, Nov 25, 2014 at 08:33:50AM +0100, Gianluca Anzolin wrote:
> > I'm a little bit uncertain what's really best to do with getopt_long,
> > but since there's a pending patch for abbreviated long options and
> > there's demand to add GNU-style argv permutation to getopt_long (but
> > not plain getopt), this code is likely to need major changes anyway
> > in this release cycle, so I'm not too concerned that we do it the
> > "best possible way" right now anyway. So if it works we can probably
> > go with it.
> > 
> 
> I tested the changes and verified that they work correctly. However I found
> something worth mentioning, not caused by the patch itself.
> 
> For a command line like the following (optstring="a:b:c:def")
> 
> $ ./test -a 1 -b 2 -c 3 -d -e -f
> 
> for the options d, e and f the variable optarg is "3". Maybe this is the
> intended behaviour, after all those options aren't supposed to get an argument,
> but glibc always sets optarg to NULL in these cases.

This is a bug in glibc. getopt is specified to set optarg only in the
case where the option takes an argument.

Rich


      reply	other threads:[~2014-11-25  7:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 18:39 Gianluca Anzolin
2014-11-25  2:48 ` Rich Felker
2014-11-25  7:33   ` Gianluca Anzolin
2014-11-25  7:39     ` Rich Felker [this message]

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=20141125073932.GR29621@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).