GNU bug report logs -
#14299
Incorrect output of `printf "\\n"`
Previous Next
Reported by: Pavel Elkind <elkind <at> chalmers.se>
Date: Mon, 29 Apr 2013 00:20:02 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14299 in the body.
You can then email your comments to 14299 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#14299
; Package
coreutils
.
(Mon, 29 Apr 2013 00:20:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Pavel Elkind <elkind <at> chalmers.se>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Mon, 29 Apr 2013 00:20:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Dear developers,
I found the following potential bug in printf (version 8.17).
Actual result:
`printf "\\n"` prints a newline caracter.
Expected result:
`printf "\\n"` prints a sequence of two individual characters, '\' and 'n', like '\n', but not a newline character.
Please address the above issue,
Many thanks,
Pavel
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org
.
(Mon, 29 Apr 2013 15:43:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Mon, 29 Apr 2013 15:43:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
Pavel Elkind <elkind <at> chalmers.se>
:
bug acknowledged by developer.
(Mon, 29 Apr 2013 15:43:03 GMT)
Full text and
rfc822 format available.
Message #12 received at 14299-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 14299 notabug
thanks
On 04/28/2013 12:44 PM, Pavel Elkind wrote:
> Dear developers,
>
> I found the following potential bug in printf (version 8.17).
>
> Actual result:
> `printf "\\n"` prints a newline caracter.
Of course. That's what POSIX requires it to print.
$ set -x
$ printf ".\\n."
+ printf '.\n.'
.
.
$ set -
>
> Expected result:
> `printf "\\n"` prints a sequence of two individual characters, '\' and 'n', like '\n', but not a newline character.
If you want printf to print a literal backslash, you have to properly
escape it. There are two levels of escaping to consider; shell escaping
(before printf ever sees its argv), and printf escaping. You missed a
level, because you forgot that within "", the shell converts \\ into a
literal \ as part of the argv, and as my 'set -x' trace showed above,
you were passing only one backslash, not two, to printf. Within printf,
when it sees the single backslash-n sequence, it converts that escape
sequence to newline.
You probably meant to do any one of these equivalent actions:
printf '.\\n.'
printf .\\\\n.
printf ".\\\\n."
all of which result in the argv handed to printf still containing two
backslashes.
As such, I'm closing this as not a bug, although you may continue to
reply here if you have further comments.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#14299
; Package
coreutils
.
(Mon, 29 Apr 2013 15:51:01 GMT)
Full text and
rfc822 format available.
Message #15 received at submit <at> debbugs.gnu.org (full text, mbox):
On Sun, 28 Apr 2013 18:44:23 +0000, Pavel Elkind <elkind <at> chalmers.se> wrote:
> Dear developers,
>
> I found the following potential bug in printf (version 8.17).
>
> Actual result:
> `printf "\\n"` prints a newline caracter.
>
> Expected result:
> `printf "\\n"` prints a sequence of two individual characters, '\' and
> 'n', like '\n', but not a newline character.
>
> Please address the above issue,
printf '\\n'
is what you want. Printf has nothing to do with this, it's the shell that
interpolates \\ when it's in double quotes.
--
D.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 28 May 2013 11:24:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 29 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.