From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6618 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] getopt: add support for non-option arguments Date: Tue, 25 Nov 2014 02:39:32 -0500 Message-ID: <20141125073932.GR29621@brightrain.aerifal.cx> References: <1416854345-5252-1-git-send-email-gianluca@sottospazio.it> <20141125024801.GP29621@brightrain.aerifal.cx> <20141125073350.GA8419@sottospazio.it> 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 1416901194 26343 80.91.229.3 (25 Nov 2014 07:39:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2014 07:39:54 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6631-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 25 08:39:48 2014 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 1XtAiw-0000kk-Lc for gllmg-musl@m.gmane.org; Tue, 25 Nov 2014 08:39:46 +0100 Original-Received: (qmail 12095 invoked by uid 550); 25 Nov 2014 07:39:45 -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 12087 invoked from network); 25 Nov 2014 07:39:44 -0000 Content-Disposition: inline In-Reply-To: <20141125073350.GA8419@sottospazio.it> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6618 Archived-At: 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