From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: "Harald van Dijk" <truedfx@gentoo.org>
Cc: zsh-workers@sunsite.dk
Subject: Re: printf bug(s?)
Date: Fri, 17 Jun 2005 10:15:07 +0200 [thread overview]
Message-ID: <8037.1118996107@trentino.groupinfra.com> (raw)
In-Reply-To: <42B2203B.3060602@gentoo.org>
Harald van D?k wrote:
> When I run the command printf '%', zsh 4.2.5 gives me a segfault. It
I can't reproduce the segfault on any system I have access to so perhaps
it is platform specific. Your fix looks right so I'll commit it to
CVS. Thanks.
> 2:
>
> That segfault I noticed when I tried to run printf '\045'. I expected
> this to print a single character '%', the same as printf '%%' would. zsh
> instead treats it exactly as an ordinary % character. Is this a bug, or
It's not a bug as such. Note that it is entirely consistent with how
printf works from C. I think there was a brief discussion about it when
printf was first added.
The current implementation makes it easier to share the \ handling code
with echo. It just calls getkeystring() on the whole format
specification first. I seem to remember that, at the time, a survey of
how other printf implementations worked showed a complete mix so it
seemed justifiable to take the lazy option. However, I would agree that
your expected behaviour would probably be better.
> " "\ddd", where ddd is a one, two, or three-digit octal number, shall
> be written as a byte with the numeric value specified by the octal
> number. "
It's difficult to know whether it was intended by the wording or not.
However, that wording also means that \7 should output a bell character
(you need \07 at the moment). Annoyingly, the specification for how \
escapes work is subtly different for echo and printf. I think \c has a
different definition too.
So what we probably need to do is have the printf code handle \ escapes
itself at the same time as it scans through the specification looking
for format specifiers.
Oliver
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
next prev parent reply other threads:[~2005-06-17 8:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-17 0:58 Harald van Dijk
2005-06-17 8:15 ` Oliver Kiddle [this message]
2005-06-17 13:22 ` Harald van Dijk
2005-06-17 13:48 ` J
2005-06-17 15:47 ` Bart Schaefer
2005-06-21 9:19 ` Oliver Kiddle
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=8037.1118996107@trentino.groupinfra.com \
--to=okiddle@yahoo.co.uk \
--cc=truedfx@gentoo.org \
--cc=zsh-workers@sunsite.dk \
/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).