GNU bug report logs -
#10620
Improper handling of newline characters
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10620 in the body.
You can then email your comments to 10620 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#10620
; Package
coreutils
.
(Fri, 27 Jan 2012 04:42:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Philippe Grégoire <gregoirep <at> hotmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 27 Jan 2012 04:42:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
I am using GNU coreutils 8.5 (I know it is not the newest, thanks
Debian) and found an issue regarding the handling of newline characters.
If I type the command '/usr/bin/printf "hi\b"', the result is as
expected -- "h" without a newline character. However, if I type
'/usr/bin/printf "hi\b\n"', the result is "hi" followed by a newline.
The newline character seems to force a buffer flush without respecting
what precedes it. The behavior is the same no matter what precedes the
backspace character and the number of backspace characters -- try "a\b\b\n".
Now testing the same strings using the C version of printf (libc6
2.11.2), I get the same result. As such, I am wondering if it is the
result of a bug in the terminal driver; sorry to bother, I discovered it
using. I tested with bash, dash, konsole, xterm and a linux console with
the same results.
By the way, I get the same behavior using "/bin/echo -e" with and
without the -n flag".
Thank you for your work!
Philippe
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#10620
; Package
coreutils
.
(Fri, 27 Jan 2012 10:06:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 10620 <at> debbugs.gnu.org (full text, mbox):
tags 10620 + notabug moreinfo
thanks
Philippe Grégoire wrote:
> If I type the command '/usr/bin/printf "hi\b"', the result is as
> expected -- "h" without a newline character.
Actually it is "hi\b". It isn't "h".
$ printf "hi\b\n" | od -tx1 -c
0000000 68 69 08 0a
h i \b \n
I don't know why you would think it would be "h" only. That would be
incorrect.
> However, if I type '/usr/bin/printf "hi\b\n"', the result is "hi"
> followed by a newline.
Right. That is what you are specifying.
$ printf "hi\b\n" | od -tx1 -c
0000000 68 69 08 0a
h i \b \n
> The newline character seems to force a buffer flush without respecting
> what precedes it.
Huh? The buffer is going to be flushed regardless when the printf
program exits. If it wasn't flushed then the output would be lost.
And the program will be exiting at that point regardless.
> The behavior is the same no matter what precedes the backspace
> character and the number of backspace characters -- try "a\b\b\n".
Right. That is the way it is supposed to work.
$ printf "a\b\b\n" | od -tx1 -c
0000000 61 08 08 0a
a \b \b \n
All as expected. Right?
> Now testing the same strings using the C version of printf (libc6
> 2.11.2), I get the same result.
Unsurprising, no? The command line printf is intentionally not much
removed from the behavior of the library routine.
> As such, I am wondering if it is the result of a bug in the terminal
> driver;
What would be the bug? Please explain what you are expecting to see.
> sorry to bother, I discovered it using. I tested with bash,
> dash, konsole, xterm and a linux console with the same results.
So if all of those different programs all do the same thing then it
would seem that the likelihood of it being a bug is very small.
Because surely somewhere along the way someone would have noticed a
bug if it were there and reported it. Since they all behave the same
it is very unlikely that it is actually a bug.
> By the way, I get the same behavior using "/bin/echo -e" with and
> without the -n flag".
Right. But 'echo' is not portable if options, arguments that might be
confused with options, or any control character sequence is included.
Use of echo is only good for plain and simple strings and nothing more.
I don't see any bug anywhere here. You have only stated that it is
behaving as itis supposed to behave. Please say what bug you think
exists.
Bob
Added tag(s) notabug and moreinfo.
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Fri, 27 Jan 2012 10:06:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#10620
; Package
coreutils
.
(Fri, 27 Jan 2012 10:13:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 10620 <at> debbugs.gnu.org (full text, mbox):
Bob Proulx wrote:
> Philippe Grégoire wrote:
> > If I type the command '/usr/bin/printf "hi\b"', the result is as
> > expected -- "h" without a newline character.
>
> Actually it is "hi\b". It isn't "h".
>
> $ printf "hi\b\n" | od -tx1 -c
> 0000000 68 69 08 0a
> h i \b \n
Oops. Cut-n-paste error. Obviously I meant to say:
$ printf "hi\b" | od -tx1 -c
0000000 68 69 08
h i \b
That didn't change anything else however.
Bob
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Fri, 27 Jan 2012 10:29:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Philippe Grégoire <gregoirep <at> hotmail.com>
:
bug acknowledged by developer.
(Fri, 27 Jan 2012 10:29:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 10620-done <at> debbugs.gnu.org (full text, mbox):
On 01/27/2012 04:16 AM, Philippe Grégoire wrote:
> Hi,
>
> I am using GNU coreutils 8.5 (I know it is not the newest, thanks
> Debian) and found an issue regarding the handling of newline characters.
>
> If I type the command '/usr/bin/printf "hi\b"', the result is as
> expected -- "h" without a newline character. However, if I type
> '/usr/bin/printf "hi\b\n"', the result is "hi" followed by a newline.
> The newline character seems to force a buffer flush without respecting
> what precedes it. The behavior is the same no matter what precedes the
> backspace character and the number of backspace characters -- try "a\b\b\n".
>
> Now testing the same strings using the C version of printf (libc6
> 2.11.2), I get the same result. As such, I am wondering if it is the
> result of a bug in the terminal driver; sorry to bother, I discovered it
> using. I tested with bash, dash, konsole, xterm and a linux console with
> the same results.
>
> By the way, I get the same behavior using "/bin/echo -e" with and
> without the -n flag".
>
>
> Thank you for your work!
The confusion here is that \b moves back, but does not delete.
So \b chars right before \n are ineffectual.
The reason it seems to work when no newline is entered,
is because the shell is writing the prompt over the backspaced chars.
I think this is illustrative:
$ env printf "hi\b\ba\n"
ai
cheers,
Pádraig.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 24 Feb 2012 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 113 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.