From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11860 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: getopt() not exposing __optpos - shell needs it Date: Tue, 29 Aug 2017 13:38:01 -0400 Message-ID: <20170829173801.GB1627@brightrain.aerifal.cx> References: <20170828152844.GY1627@brightrain.aerifal.cx> <20170829122014.GZ1627@brightrain.aerifal.cx> <20170829130757.GA1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1504028299 32097 195.159.176.226 (29 Aug 2017 17:38:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2017 17:38:19 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11873-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 29 19:38:16 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dmkSm-0007kZ-C4 for gllmg-musl@m.gmane.org; Tue, 29 Aug 2017 19:38:08 +0200 Original-Received: (qmail 16255 invoked by uid 550); 29 Aug 2017 17:38:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 16237 invoked from network); 29 Aug 2017 17:38:13 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11860 Archived-At: On Tue, Aug 29, 2017 at 06:47:24PM +0200, Denys Vlasenko wrote: > On Tue, Aug 29, 2017 at 3:07 PM, Rich Felker wrote: > >> > Maybe I'm missing what you're trying to say, but all the state is > >> > clobbered; I don't see how optarg is a problem specifically. You can > >> > clear or set it to a sentinel value before the relevant call if you're > >> > trying to determine if the call set it. Across other calls (not the > >> > one for the current option) I don't see why it matters at all what > >> > happens to it. > >> > >> Yes, this can be done. > >> > >> It gets increasigly ugly, though. > >> > >> With these amounts of massaging around libc API design breakage, > > > > Yes the getopt API is horribly broken. It's all global state, with a > > tiny portion of that state internal/inaccessible. It doesn't follow > > that the solution is adding new extensions every time an application > > hits an obstacle from the brokenness. The right direction for fixing > > it on the libc side would be introduction (with consensus across > > important implementations) of a getopt_r API or similar with no > > global/internal state. > > I don't understand why you are opposed to exposing __optpos. > It does not even require any coding. Not a single insn needs > to be added. New public interfaces are a lot more expensive than new code. The latter can be changed or removed; the former can't. Over the past 6+ years, just about the only other party asking musl to add newly-invented nonstandard interfaces without existing precedent was gnulib, and after a lot of discussion that made sense because they were already doing the equivalent on other libcs through hideous poking at internals that were never meant to be exposed, and because the new interfaces fixed compatibility with tens (or more) of packages using gnulib that weren't even aware of its dependencies on poking at internals. OTOH you've requested this kind of thing for busybox hush twice over just a month or so, and in this case the (getopt) the same can clearly be achieved portably through the existing interfaces so there's not even a need. Rich