mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: getopt() not exposing __optpos - shell needs it
Date: Tue, 29 Aug 2017 13:38:01 -0400	[thread overview]
Message-ID: <20170829173801.GB1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAK1hOcM1bJzBCPXFXQUb-U5MANAkma5CyT_nD6pqRu10HRXzLw@mail.gmail.com>

On Tue, Aug 29, 2017 at 06:47:24PM +0200, Denys Vlasenko wrote:
> On Tue, Aug 29, 2017 at 3:07 PM, Rich Felker <dalias@libc.org> 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


      reply	other threads:[~2017-08-29 17:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 10:18 Denys Vlasenko
2017-08-28 15:17 ` Denys Vlasenko
2017-08-28 15:28 ` Rich Felker
2017-08-29 11:32   ` Denys Vlasenko
2017-08-29 12:20     ` Rich Felker
2017-08-29 12:47       ` Denys Vlasenko
2017-08-29 13:07         ` Rich Felker
2017-08-29 16:47           ` Denys Vlasenko
2017-08-29 17:38             ` 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=20170829173801.GB1627@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).