zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: printf \045 (or whatever the character code for % is)
Date: Wed, 5 Jan 2011 17:39:44 +0000	[thread overview]
Message-ID: <20110105173944.47123402@pws-pc.ntlworld.com> (raw)
In-Reply-To: <20101229211155.GA22720@stack.nl>

On Wed, 29 Dec 2010 22:11:55 +0100
Jilles Tjoelker <jilles@stack.nl> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  parent reply	other threads:[~2011-01-05 17:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-29 21:11 Jilles Tjoelker
2010-12-29 23:55 ` Alexey I. Froloff
2011-01-05 17:39 ` Peter Stephenson [this message]
2011-01-06  4:46   ` Bart Schaefer
2011-01-06 12:09     ` Peter Stephenson
2011-01-06 16:01       ` Bart Schaefer

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=20110105173944.47123402@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /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/zsh/

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).