From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20378 invoked by alias); 5 Jan 2011 17:56:29 -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: 28569 Received: (qmail 3506 invoked from network); 5 Jan 2011 17:56:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.56 as permitted sender) Date: Wed, 5 Jan 2011 17:39:44 +0000 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: printf \045 (or whatever the character code for % is) Message-ID: <20110105173944.47123402@pws-pc.ntlworld.com> In-Reply-To: <20101229211155.GA22720@stack.nl> References: <20101229211155.GA22720@stack.nl> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.0; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=1lNBomd0ogsA:10 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=Emjv4DOJ8OpdhzW5hV4A:9 a=qwFvf9rHHzYbxa-mtqkA:7 a=Jy60dngAbIIR62keNgMI0UkjGOsA:4 a=CjuIK1q_8ugA:10 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 On Wed, 29 Dec 2010 22:11:55 +0100 Jilles Tjoelker wrote: > While trying to run the FreeBSD sh testsuite with zsh, various tests > fail because the printf builtin interprets \045 (ASCII) as a percent > sign introducing a format specification instead of a literal percent > sign. The \045 arises because I create all 255 non-zero byte values via > octal escapes. > > POSIX's description assumes that the backslash escapes and format > specifications are processed in one pass and simply says that an octal > escape sequence shall write the corresponding byte. If they are separate > passes the backslash escape removal step needs to know about percent > signs. That's a reasonable assumption, but the function handling print is an appalling mess so it's not easy to fix without a major rewrite. The code for printf doesn't really have any business being associated with the code for print, they're there for different purposes entirely based on completely different specifications. At the moment printf does the same as 'print -f', so it has all the same oddities as print whether it should or not. (In my opinion, anyone deliberately asking for combined print and printf behaviour deserves everything they get so I'm perfectly happy to let 'print -f' fester while standardising printf.) However, I never get volunteers for tidying the shell up, so we're probably stuck until someone gets fed up enough to look into it. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/