From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2030 Path: news.gmane.org!not-for-mail From: =?ISO-8859-2?Q?Daniel_Cegie=B3ka?= Newsgroups: gmane.linux.lib.musl.general Subject: Re: better compatibility with bsd getopt() Date: Sun, 30 Sep 2012 23:06:55 +0200 Message-ID: References: <5068B362.5070408@barfooze.de> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1349039252 18560 80.91.229.3 (30 Sep 2012 21:07:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Sep 2012 21:07:32 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2031-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 30 23:07:36 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TIQjd-0008By-CW for gllmg-musl@plane.gmane.org; Sun, 30 Sep 2012 23:07:33 +0200 Original-Received: (qmail 11448 invoked by uid 550); 30 Sep 2012 21:07:27 -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 11440 invoked from network); 30 Sep 2012 21:07:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=QoinU4T4qlX1zt/ght9r+H+DfKDwizBaHaqGOr7nieA=; b=cAAO+muYqLLaj8N93bhBMvR4oFMHt0SNE08bQiQte+8dQOe/UcWh3brNKeKizzKTVH p10ExetJL5MVuXH93h0mo0E1XiJmzUH7HMOWWN0sYKuUOBj4hxhS5YBrcf9yVNiOkPhy rlkx+TowwGV7AAhwnSK9cxY4KX33FH7tv7d8puRISfa0KcmDhh7Ghh99IIrjazhhbWTu tHh+FfJPV98ByQf32ybo8qRi8TnNs3qJAryU10N6JhADQjnFJtLeDtmBrYCYsoPucxBW gIXja7HDhV/QFa3wi1UWF7a1RXJ5Nkd00tItGwKP26z96JeNDQMc8XfDG2JHKr8zFa9o ZLKA== In-Reply-To: <5068B362.5070408@barfooze.de> Xref: news.gmane.org gmane.linux.lib.musl.general:2030 Archived-At: 2012/9/30 John Spencer : > an application that relies on non-posix getopt behaviour should come with a > configure check and use an alternate impl if the getopt detected is not > compatible. > almost any program does so already, but for those that don't (like iptables) > you can use https://github.com/rofl0r/gnu-getopt (tarball available on > sabotage mirror, or in downloads section of the page). > this bundles the netbsd getopt into a standalone library that can easily be > linked to programs. Without optreset support some BSD programs will not be able to compile, like patch: if (!Argc) return; optreset = optind = 1; while ((ch = getopt_long(Argc, Argv, options, longopts, NULL)) != -1) { switch (ch) { case 'b': http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/patch/patch.c?rev=1.50;content-type=text%2Fplain Your example shows that the gnu-getopt is also a problem. It may be better to keep musl clean and solve these problems outside of musl. So a good solution for us is to use a getopt() wrapper for problematic apps, like gnu_getopt() or bsd_getopt(). Daniel