From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6708 Path: news.gmane.org!not-for-mail From: Laurent Bercot Newsgroups: gmane.linux.lib.musl.general Subject: Re: possible getopt stderr output changes Date: Thu, 11 Dec 2014 04:53:52 +0100 Message-ID: <54891550.901@skarnet.org> References: <20141211001032.GA5421@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1418270047 24744 80.91.229.3 (11 Dec 2014 03:54:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2014 03:54:07 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6721-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 11 04:54:00 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 1XyupE-0008AL-BV for gllmg-musl@m.gmane.org; Thu, 11 Dec 2014 04:54:00 +0100 Original-Received: (qmail 12158 invoked by uid 550); 11 Dec 2014 03:53:59 -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 12150 invoked from network); 11 Dec 2014 03:53:58 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <20141211001032.GA5421@brightrain.aerifal.cx> X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejiedrgedvgdehkecutefuodetggdotefrucfrrhhofhhilhgvmecupfgfoffgtffkveetuefngfenuceurghilhhouhhtmecufedttdenucenucfjughrpefkfffhfgggvffufhgjtgfgsehtjegrtddtfeejnecuhfhrohhmpefnrghurhgvnhhtuceuvghrtghothcuoehskhgrqdguihgvthhlihgstgesshhkrghrnhgvthdrohhrgheq Xref: news.gmane.org gmane.linux.lib.musl.general:6708 Archived-At: On 11/12/2014 01:10, Rich Felker wrote: > The current getopt code uses some ugly write() sequences to generate > its output to stderr, and fails to support message translation. The > latter was an oversight when locale/translation support was added and > should absolutely be fixed. I'm not sure whether we should leave the > code using write() though or switch to fprintf. For what is worth, I may use getopt() sometime, but I will never, ever use stdio, which should burn in the deepest pits of Hell, and I'm being nuanced here. Please don't tie a reasonable interface to the flying kitchen sink monster just because it's guilty of having to write stuff to stderr in one particular case. It doesn't deserve that much punishment. > printf/stdio. However, the use of multiple write() calls splits the > messages up into multiple syscalls unnecessarily (increasing the > likelihood of getting output interleaved with other processes running > in parallel on the same stderr) It is rare for getopt to return a parsing error when the program is used without an interactive terminal: scripts are usually debugged before they're daemonized. Most use cases of getopt writing to stderr are interactive, so the likelihood of interleaving output is low. That said, I'm all for buffering, but is there anything more to do than print localized versions of "illegal option" and "option requires an argument", with some locale-independent data prepended and appended ? Isn't it possible to compute the size of the final string in advance, and build it in a temporary buffer on the stack, before writing ? It's simple buffering: neither stdio's formatting engine, nor its FILE plate of noodles, are needed. > Thoughts on what color the bikeshed should be? I don't mind the color, but let's keep it SUV-free. -- Laurent