From unknown Sat Jun 14 19:00:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10620: Improper handling of newline characters Resent-From: Philippe =?UTF-8?Q?Gr=C3=A9goire?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Jan 2012 04:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10620 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 10620@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13276392927012 (code B ref -1); Fri, 27 Jan 2012 04:42:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Jan 2012 04:41:32 +0000 Received: from localhost ([127.0.0.1]:46022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rqdcx-0001p2-0P for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:41:32 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51890) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RqdF2-0001Gj-Vz for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:16:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqdEN-0005Lc-6V for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:16:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RECEIVED_FROM_WINDOWS_HOST, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:37394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqdEN-0005LY-1T for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:16:07 -0500 Received: from eggs.gnu.org ([140.186.70.92]:59546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqdEL-0007WH-QD for bug-coreutils@gnu.org; Thu, 26 Jan 2012 23:16:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqdEK-0005LE-Ab for bug-coreutils@gnu.org; Thu, 26 Jan 2012 23:16:05 -0500 Received: from blu0-omc3-s6.blu0.hotmail.com ([65.55.116.81]:39897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqdEK-0005L7-8c for bug-coreutils@gnu.org; Thu, 26 Jan 2012 23:16:04 -0500 Received: from BLU0-SMTP110 ([65.55.116.73]) by blu0-omc3-s6.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jan 2012 20:16:03 -0800 X-Originating-IP: [209.197.162.169] X-Originating-Email: [gregoirep@hotmail.com] Message-ID: Received: from [192.168.0.7] ([209.197.162.169]) by BLU0-SMTP110.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jan 2012 20:16:01 -0800 Date: Thu, 26 Jan 2012 23:16:04 -0500 From: Philippe =?UTF-8?Q?Gr=C3=A9goire?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Jan 2012 04:16:01.0743 (UTC) FILETIME=[6108F5F0:01CCDCAA] X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -3.5 (---) X-Mailman-Approved-At: Thu, 26 Jan 2012 23:41:29 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) 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 From unknown Sat Jun 14 19:00:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10620: Improper handling of newline characters Resent-From: Bob Proulx Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Jan 2012 10:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10620 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Philippe =?UTF-8?Q?Gr=C3=A9goire?= Cc: 10620@debbugs.gnu.org Received: via spool by 10620-submit@debbugs.gnu.org id=B10620.132765872515765 (code B ref 10620); Fri, 27 Jan 2012 10:06:01 +0000 Received: (at 10620) by debbugs.gnu.org; 27 Jan 2012 10:05:25 +0000 Received: from localhost ([127.0.0.1]:46218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RqigN-00046B-At for submit@debbugs.gnu.org; Fri, 27 Jan 2012 05:05:24 -0500 Received: from joseki.proulx.com ([216.17.153.58]:54792) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RqigK-00045x-33; Fri, 27 Jan 2012 05:05:21 -0500 Received: from discord.proulx.com (discord.proulx.com [172.27.61.2]) (Authenticated sender: discord) by joseki.proulx.com (Postfix) with ESMTPA id 26DD8211D8; Fri, 27 Jan 2012 03:04:42 -0700 (MST) Received: by discord.proulx.com (Postfix, from userid 1000) id CB3DC90C06E; Fri, 27 Jan 2012 03:04:41 -0700 (MST) Date: Fri, 27 Jan 2012 03:04:41 -0700 From: Bob Proulx Message-ID: <20120127100441.GA14661@discord.proulx.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) tags 10620 + notabug moreinfo thanks Philippe Gr=E9goire 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 From unknown Sat Jun 14 19:00:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10620: Improper handling of newline characters Resent-From: Bob Proulx Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Jan 2012 10:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10620 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: notabug moreinfo To: Philippe =?UTF-8?Q?Gr=C3=A9goire?= Cc: 10620@debbugs.gnu.org Received: via spool by 10620-submit@debbugs.gnu.org id=B10620.132765917316440 (code B ref 10620); Fri, 27 Jan 2012 10:13:01 +0000 Received: (at 10620) by debbugs.gnu.org; 27 Jan 2012 10:12:53 +0000 Received: from localhost ([127.0.0.1]:46242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rqinc-0004H6-Fo for submit@debbugs.gnu.org; Fri, 27 Jan 2012 05:12:53 -0500 Received: from joseki.proulx.com ([216.17.153.58]:54821) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rqina-0004Gz-J5 for 10620@debbugs.gnu.org; Fri, 27 Jan 2012 05:12:51 -0500 Received: from discord.proulx.com (discord.proulx.com [172.27.61.2]) (Authenticated sender: discord) by joseki.proulx.com (Postfix) with ESMTPA id F3E05211D8; Fri, 27 Jan 2012 03:12:12 -0700 (MST) Received: by discord.proulx.com (Postfix, from userid 1000) id CD380D395CD; Fri, 27 Jan 2012 03:12:12 -0700 (MST) Date: Fri, 27 Jan 2012 03:12:12 -0700 From: Bob Proulx Message-ID: <20120127101212.GB14661@discord.proulx.com> References: <20120127100441.GA14661@discord.proulx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20120127100441.GA14661@discord.proulx.com> User-Agent: Mutt/1.5.18 (2008-05-17) Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Bob Proulx wrote: > Philippe Gr=E9goire wrote: > > If I type the command '/usr/bin/printf "hi\b"', the result is as > > expected -- "h" without a newline character. >=20 > Actually it is "hi\b". It isn't "h". >=20 > $ 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 From unknown Sat Jun 14 19:00:40 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Philippe =?UTF-8?Q?Gr=C3=A9goire?= Subject: bug#10620: closed (Re: bug#10620: Improper handling of newline characters) Message-ID: References: <4F227C31.2030202@draigBrady.com> X-Gnu-PR-Message: they-closed 10620 X-Gnu-PR-Package: coreutils X-Gnu-PR-Keywords: notabug moreinfo Reply-To: 10620@debbugs.gnu.org Date: Fri, 27 Jan 2012 10:29:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1327660142-20759-1" This is a multi-part message in MIME format... ------------=_1327660142-20759-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #10620: Improper handling of newline characters which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 10620@debbugs.gnu.org. --=20 10620: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D10620 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1327660142-20759-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 10620-done) by debbugs.gnu.org; 27 Jan 2012 10:28:47 +0000 Received: from localhost ([127.0.0.1]:46247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rqj30-0005OK-GV for submit@debbugs.gnu.org; Fri, 27 Jan 2012 05:28:47 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:31810) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rqj2z-0005O8-2s for 10620-done@debbugs.gnu.org; Fri, 27 Jan 2012 05:28:45 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAKN7Ik9tTDM1/2dsb2JhbAAMN6whhSkBAQEEMgFGEAsNCwkWDwkDAgECAUUGDQEHAQHAE4N/hREBBAICBQcCAQ4GCQoKLAOCZR0MEg9iCRsDDINCBJsTjFQ Received: from unknown (HELO [192.168.1.79]) ([109.76.51.53]) by mail3.vodafone.ie with ESMTP; 27 Jan 2012 10:28:02 +0000 Message-ID: <4F227C31.2030202@draigBrady.com> Date: Fri, 27 Jan 2012 10:28:01 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Philippe_Gr=E9goire?= Subject: Re: bug#10620: Improper handling of newline characters References: In-Reply-To: X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10620-done Cc: 10620-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) 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. ------------=_1327660142-20759-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Jan 2012 04:41:32 +0000 Received: from localhost ([127.0.0.1]:46022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rqdcx-0001p2-0P for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:41:32 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51890) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RqdF2-0001Gj-Vz for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:16:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqdEN-0005Lc-6V for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:16:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RECEIVED_FROM_WINDOWS_HOST, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:37394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqdEN-0005LY-1T for submit@debbugs.gnu.org; Thu, 26 Jan 2012 23:16:07 -0500 Received: from eggs.gnu.org ([140.186.70.92]:59546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqdEL-0007WH-QD for bug-coreutils@gnu.org; Thu, 26 Jan 2012 23:16:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqdEK-0005LE-Ab for bug-coreutils@gnu.org; Thu, 26 Jan 2012 23:16:05 -0500 Received: from blu0-omc3-s6.blu0.hotmail.com ([65.55.116.81]:39897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqdEK-0005L7-8c for bug-coreutils@gnu.org; Thu, 26 Jan 2012 23:16:04 -0500 Received: from BLU0-SMTP110 ([65.55.116.73]) by blu0-omc3-s6.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jan 2012 20:16:03 -0800 X-Originating-IP: [209.197.162.169] X-Originating-Email: [gregoirep@hotmail.com] Message-ID: Received: from [192.168.0.7] ([209.197.162.169]) by BLU0-SMTP110.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jan 2012 20:16:01 -0800 Date: Thu, 26 Jan 2012 23:16:04 -0500 From: =?ISO-8859-1?Q?Philippe_Gr=E9goire?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: Improper handling of newline characters X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Jan 2012 04:16:01.0743 (UTC) FILETIME=[6108F5F0:01CCDCAA] X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 26 Jan 2012 23:41:29 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) 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 ------------=_1327660142-20759-1--