GNU bug report logs - #10620
Improper handling of newline characters

Previous Next

Package: coreutils;

Reported by: Philippe Grégoire <gregoirep <at> hotmail.com>

Date: Fri, 27 Jan 2012 04:42:01 UTC

Severity: normal

Tags: moreinfo, notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Pádraig Brady <P <at> draigBrady.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#10620: closed (Improper handling of newline characters)
Date: Fri, 27 Jan 2012 10:29:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 27 Jan 2012 10:28:01 +0000
with message-id <4F227C31.2030202 <at> draigBrady.com>
and subject line Re: bug#10620: Improper handling of newline characters
has caused the debbugs.gnu.org bug report #10620,
regarding Improper handling of newline characters
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
10620: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10620
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Philippe Grégoire <gregoirep <at> hotmail.com>
To: bug-coreutils <at> gnu.org
Subject: Improper handling of newline characters
Date: Thu, 26 Jan 2012 23:16:04 -0500
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


[Message part 3 (message/rfc822, inline)]
From: Pádraig Brady <P <at> draigBrady.com>
To: Philippe Grégoire <gregoirep <at> hotmail.com>
Cc: 10620-done <at> debbugs.gnu.org
Subject: Re: bug#10620: Improper handling of newline characters
Date: Fri, 27 Jan 2012 10:28:01 +0000
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.


This bug report was last modified 13 years and 161 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.