From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11859 Path: news.gmane.org!.POSTED!not-for-mail From: Denys Vlasenko Newsgroups: gmane.linux.lib.musl.general Subject: Re: getopt() not exposing __optpos - shell needs it Date: Tue, 29 Aug 2017 18:47:24 +0200 Message-ID: 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="UTF-8" X-Trace: blaine.gmane.org 1504025315 11653 195.159.176.226 (29 Aug 2017 16:48:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2017 16:48:35 +0000 (UTC) To: musl Original-X-From: musl-return-11872-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 29 18:48:31 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 1dmjgb-0002O6-M3 for gllmg-musl@m.gmane.org; Tue, 29 Aug 2017 18:48:21 +0200 Original-Received: (qmail 22295 invoked by uid 550); 29 Aug 2017 16:47:58 -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 22215 invoked from network); 29 Aug 2017 16:47:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=fIiCfyD4YaeXgtrqcxAvGPhr9cWlocvS4Y7rKWkT2k4=; b=KVcP6ud+W8EMI7CtOyT90tUJR61wlvV5AMbw6sf94Ud57acd21ZNycLYxKbuIsjbPW bvDTHNEkBgVZNcGMpmd3rOCKxNq4taxgF1jz/FHh4VGAYjqF7J4Mkewi7NaQnEyiGX1J bHtePwL4Ue7F1iZJIb7kGTPSVgR5A2i9pFr6AdS4PQ0Lm8sL0G9wKID612fM1PgYM9Wa MbgXejKCsRJn5SOmSbH6qsvvpU+xuSpGztwgbhpSuW7DEpnpcJT60WxhpMaA3/lwyXje 4ZRpvikX5t4zd+sD/ZBZJcAJ8/aZePTfmwvqGthirSgHvpWKnjazJRpe8TdwoKfZO4N/ 3IAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=fIiCfyD4YaeXgtrqcxAvGPhr9cWlocvS4Y7rKWkT2k4=; b=raTGGVhQEoH9NOW7CS7HHb4EhNy9ZicZ6I1BI1Up39LZsqexg4xCfo4JeUUhonbWlP /65PYGhzQH8qjAXdKNaHnxE0bH7sEursQ6XFw0Bwq7ep3X2JbeRnG6En3fAljQDiYMVv eVTo6iVSM+KSKFxrOmpmlVxF5d5oeLNoYMsjpx/MLrjzBq+tMA8NwBTTeboSQaRET7q1 qa0IyRc5ABJo4kMrYZaFrlBHOJaAkvtDUpqyQUnnVM5OJi/CHBPyvcJHgNxjJSb59VAf od5V94FHUuiB6Ip3eszMF5N/tcEEyhl5Ku2Gx74TNBDvm1/1+Pr0BxMtiw06prpzgMeE sgkA== X-Gm-Message-State: AHYfb5j/qr9y5B4w19SZlcUWxDIAPLtgR6GT1p4taqc8pRm6yptTTp+9 S/aQo2RdU7Sv+MFJgKzh/mA6ZyBujg== X-Google-Smtp-Source: ADKCNb7UWlk/kCVKl8i8AzLXFgnOUZm2t+02ol/0q2Lgm7x8E4i8lHa83WLTeYTXgnMLxMszP3vBv1m1fL4MolKC6/g= X-Received: by 10.80.207.129 with SMTP id h1mr3970711edk.120.1504025265466; Tue, 29 Aug 2017 09:47:45 -0700 (PDT) In-Reply-To: <20170829130757.GA1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:11859 Archived-At: 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.