From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10331 invoked by alias); 7 Jun 2015 21:20:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35413 Received: (qmail 3870 invoked from network); 7 Jun 2015 21:20:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.0 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Stephane Chazelas Subject: Re: printf, left-justification ignored in 5.0.8 Date: Sun, 7 Jun 2015 22:15:29 +0100 Message-ID: <20150607211529.GA13370@chaz.gmail.com> References: <20150607081142.GF15174@isis.sigpipe.cz> <30271.1433709564@thecus.kiddle.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 05448b1b.skybroadband.com Content-Disposition: inline In-Reply-To: <30271.1433709564@thecus.kiddle.eu> User-Agent: Mutt/1.5.21 (2010-09-15) 2015-06-07 22:39:24 +0200, Oliver Kiddle: > Roman Neuhauser wrote: > > > > 5.0.8: > > > > % printf "x:%-20s:y\n" fubar > > x: fubar:y > > That'll be my fault for not checking thoroughly enough. The - flag is > fine for numeric values but for strings it seems there is separate code > to allow for UTF-8 which looks in the flags array. The patch should > fix this, adds a test and makes the maximum specification length test > include the ' flag. [...] BTW, there was a discussion lately on the Austin group mailing list confirming that the %20s should count bytes, not characters. That is in a UTF-8 locale printf '|%3s|\n' e é € should print: | e| | é| |€| not: | e| | é| | €| I find the zsh behaviour more useful though, especially considering that in zsh we can get the POSIX behaviour with: $ LC_ALL=C printf '|%3s|\n' e é € | e| | é| |€| But note that to get proper alignment, rather than number of characters, the width of the glyphs should be considered instead anyway: $ printf '|%3b|\n' e '\ue9' 'e\u301' '\uff45' | e| | é| | é| | e| ksh93 has %3Ls for that: $ printf '|%3Ls|\n' e $'\ue9' $'e\u301' $'\uff45' | e| | é| | é| | e| (possibly uses wcswidth()). -- Stephane