GNU bug report logs - #9916
[PATCH] echo: fix octal escaping with \1...\7

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: libtool; Reported by: Eric Blake <eblake@HIDDEN>; Keywords: patch; dated Mon, 31 Oct 2011 13:16:01 UTC; Maintainer for libtool is bug-libtool@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Oct 2011 18:42:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 31 14:42:03 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1RKwo7-0004zk-3h
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 14:42:03 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <vapier@HIDDEN>) id 1RKwo1-0004zI-SN
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 14:41:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@HIDDEN>) id 1RKwlr-0004MW-Qt
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 14:39:45 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED,
	RP_MATCHES_RCVD autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:51178)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@HIDDEN>) id 1RKwlr-0004MP-Nf
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 14:39:43 -0400
Received: from eggs.gnu.org ([140.186.70.92]:56159)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@HIDDEN>) id 1RKwlq-0006e3-8F
	for bug-libtool@HIDDEN; Mon, 31 Oct 2011 14:39:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <vapier@HIDDEN>) id 1RKwlp-0004M0-2K
	for bug-libtool@HIDDEN; Mon, 31 Oct 2011 14:39:42 -0400
Received: from smtp.gentoo.org ([140.211.166.183]:50961)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <vapier@HIDDEN>) id 1RKwlo-0004Lu-Pr
	for bug-libtool@HIDDEN; Mon, 31 Oct 2011 14:39:40 -0400
Received: from vapier.localnet (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 49CC91B400B;
	Mon, 31 Oct 2011 18:39:38 +0000 (UTC)
From: Mike Frysinger <vapier@HIDDEN>
Organization: wh0rd.org
To: Eric Blake <eblake@HIDDEN>
Subject: Re: [PATCH] echo: fix octal escaping with \1...\7
Date: Mon, 31 Oct 2011 14:39:37 -0400
User-Agent: KMail/1.13.7 (Linux/3.1.0-rc4; KDE/4.6.5; x86_64; ; )
References: <20111031034146.GA19477@HIDDEN>
	<201110310023.45138.vapier@HIDDEN>
	<4EAE9ECB.4040607@HIDDEN>
In-Reply-To: <4EAE9ECB.4040607@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart12134331.pGt6qVsan4";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
Message-Id: <201110311439.38413.vapier@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: submit
Cc: Herbert Xu <herbert@HIDDEN>, dash@HIDDEN,
	bug-libtool@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

--nextPart12134331.pGt6qVsan4
Content-Type: Text/Plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

On Monday 31 October 2011 09:12:43 Eric Blake wrote:
> On 10/30/2011 10:23 PM, Mike Frysinger wrote:
> > On Sunday 30 October 2011 23:41:58 Herbert Xu wrote:
> >> Mike Frysinger wrote:
> >>> POSIX states that octal escape sequences should take the form \0num
> >>> when using echo.  dash however additionally treats \num as an octal
> >>> sequence.  This breaks some packages (like libtool) who attempt to
> >>> use strings with these escape sequences via variables to execute sed
> >>> (since sed ends up getting passed a byte instead of a literal \1).
>=20
> That's a bug in libtool for using "echo '\1'" and expecting sane
> behavior.  Can you provide more details on this libtool bug, so we can
> get it fixed in libtool?  Or perhaps it has already been fixed in modern
> libtool, and you are just encountering it in an older version?

i plan on digging through the relevant packages and posting patches where=20
applicable.  i might be wrong about the libtool side, but do know of at lea=
st=20
one ax m4 file using it (which is what started this rat hole in the first=20
place).  but i consider that a parallel issue :).

> >> OK this is a bit of problem.  From our conversation I had the
> >> impression that you were referring to the lack of support of
> >> escape codes, rather than unwanted support.
> >>=20
> >> If it was the former I could easily add it if POSIX said so,
> >> however, as this is an existing feature there may well be scripts
> >> out there that depend on it.  So removing it is not an option
> >> unless it is explicitly forbidden by POSIX.
> >=20
> > i'm not seeing how this jives with dash's goal.  if it intends to be a
> > fast/small POSIX compliant shell while punting (almost) all the rest,
> > then why carry additional functionality that POSIX doesn't even mention
> > in passing ? this isn't "documented but optional extended
> > functionality", but rather the realm of "anything goes".  otherwise we
> > approach the same realm that dash was created to avoid -- carrying lots
> > of cruft that slow things down because scripts use it rather than POSIX
> > mandating it.
> >=20
> > as a comparison, bash/ksh/tcsh/zsh/busybox[ash] all behave the way my
> > patch updates dash to operate ... i would test more shells, but these
> > tend to be the standards that everyone compares against.  i can't see
> > people writing scripts that only work under dash either.
> >=20
> >> In any case, scripts that rely on escape codes like this are
> >> simply broken and should either be fixed to use printf or just
> >> run with #!/bin/bash.
> >=20
> > they're relying on these escape codes not being interpreted as escape
> > codes (which every other shell appears to do), not the other way around
>=20
> Scripts that rely on a certain interpretation of "echo '\1'" are broken
> regardless of how dash behaves;

sure, i'm not arguing that logic

> but that said, since POSIX doesn't
> require dash's current behavior, and since the proposed patch makes dash
> both smaller and more like other shells in treating it as an extension
> that means a literal 1 rather than an octal escape, I would be in favor
> of making the change in dash.

right, that's what i'm going for
=2Dmike

--nextPart12134331.pGt6qVsan4
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJOrutqAAoJEEFjO5/oN/WBx1oP/0skpIcRcE2b1vUGPUVKwOWk
2Vqa6q7ALDEQRaqKW30cLpPk21y8/kNY4VAi9vLHT8aUbKHNdwTiS2BWZS0Vqp5i
8sIwrLkPIyVx91dZPzCSAstK99e5QjUBbJt2rqtepfYfFyY7KRASa0DyDG3WBofO
hFR4hBC9EBPLwYCjzyUvjmKihLlQSGmFjDIZ4HmLHeeXLRUm05nNcXPPuaxUMgBV
nA8YFMgNLydrt6wso/UE7M6ksQLzwGirS2PE4BB9c7ekd9WAEO8G88xUkWTidGe7
K++vqrlobiJPY6ROmFvxV740AS1FKz0MTm5TwzyrWbQ4vN5cXwpdj7vMrY4ee+B+
5bTH+WeelqJIqpKxNsIuEQHelpKU5BFySfBEkUTIvs0GCQyTnjmHVosLCXDF5rK1
MKoOb56aLqK0zJC2tFtD7Dmrv31hTkUNYGAYSZtYUcetxbSGDdfYCClVZjy3h3jQ
cuIZxRo863ROCYvo5QLgzwaOAuaWChgg/KJ0BQkxzIW13aiNN38CPbHVjBRKFsfa
r7C6EnHWHXdIcmMzyClGS0wqjEnnVxM6HZQojZMnR5gLfrglx3NVIslHOJAcus0Z
u7Aa4vIOoGG50nEvU/7FXboc3j2G9R9BzBJo9w3WEBNP755LzjBAlcOlac2UUs4A
DAcAC77KKAbchnu8esGX
=SuOL
-----END PGP SIGNATURE-----

--nextPart12134331.pGt6qVsan4--




Information forwarded to bug-libtool@HIDDEN:
bug#9916; Package libtool. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Oct 2011 13:15:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 31 09:15:10 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1RKrhl-0003im-Je
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 09:15:09 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <eblake@HIDDEN>) id 1RKrhg-0003ic-N1
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 09:15:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eblake@HIDDEN>) id 1RKrfX-0000dO-ND
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 09:12:53 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,
	RP_MATCHES_RCVD autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:52549)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eblake@HIDDEN>) id 1RKrfX-0000dK-L8
	for submit <at> debbugs.gnu.org; Mon, 31 Oct 2011 09:12:51 -0400
Received: from eggs.gnu.org ([140.186.70.92]:45423)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eblake@HIDDEN>) id 1RKrfV-0008PK-Lb
	for bug-libtool@HIDDEN; Mon, 31 Oct 2011 09:12:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eblake@HIDDEN>) id 1RKrfT-0000cO-Kq
	for bug-libtool@HIDDEN; Mon, 31 Oct 2011 09:12:49 -0400
Received: from mx1.redhat.com ([209.132.183.28]:38483)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eblake@HIDDEN>) id 1RKrfS-0000cH-Te
	for bug-libtool@HIDDEN; Mon, 31 Oct 2011 09:12:47 -0400
Received: from int-mx01.intmail.prod.int.phx2.redhat.com
	(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9VDCiA7018014
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Mon, 31 Oct 2011 09:12:44 -0400
Received: from [10.3.113.101] (ovpn-113-101.phx2.redhat.com [10.3.113.101])
	by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
	id p9VDChJh017873; Mon, 31 Oct 2011 09:12:43 -0400
Message-ID: <4EAE9ECB.4040607@HIDDEN>
Date: Mon, 31 Oct 2011 07:12:43 -0600
From: Eric Blake <eblake@HIDDEN>
Organization: Red Hat
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US;
	rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14
	Lightning/1.0b3pre Mnenhy/0.8.4 Thunderbird/3.1.15
MIME-Version: 1.0
To: Mike Frysinger <vapier@HIDDEN>
Subject: Re: [PATCH] echo: fix octal escaping with \1...\7
References: <20111031034146.GA19477@HIDDEN>
	<201110310023.45138.vapier@HIDDEN>
In-Reply-To: <201110310023.45138.vapier@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -8.0 (--------)
X-Debbugs-Envelope-To: submit
Cc: Herbert Xu <herbert@HIDDEN>, dash@HIDDEN,
	bug-libtool@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -8.0 (--------)

[adding bug-libtool]

On 10/30/2011 10:23 PM, Mike Frysinger wrote:
> On Sunday 30 October 2011 23:41:58 Herbert Xu wrote:
>> Mike Frysinger wrote:
>>> POSIX states that octal escape sequences should take the form \0num
>>> when using echo.  dash however additionally treats \num as an octal
>>> sequence.  This breaks some packages (like libtool) who attempt to
>>> use strings with these escape sequences via variables to execute sed
>>> (since sed ends up getting passed a byte instead of a literal \1).

That's a bug in libtool for using "echo '\1'" and expecting sane 
behavior.  Can you provide more details on this libtool bug, so we can 
get it fixed in libtool?  Or perhaps it has already been fixed in modern 
libtool, and you are just encountering it in an older version?

>>
>> OK this is a bit of problem.  From our conversation I had the
>> impression that you were referring to the lack of support of
>> escape codes, rather than unwanted support.
>>
>> If it was the former I could easily add it if POSIX said so,
>> however, as this is an existing feature there may well be scripts
>> out there that depend on it.  So removing it is not an option
>> unless it is explicitly forbidden by POSIX.
>
> i'm not seeing how this jives with dash's goal.  if it intends to be a
> fast/small POSIX compliant shell while punting (almost) all the rest, then why
> carry additional functionality that POSIX doesn't even mention in passing ?
> this isn't "documented but optional extended functionality", but rather the
> realm of "anything goes".  otherwise we approach the same realm that dash was
> created to avoid -- carrying lots of cruft that slow things down because
> scripts use it rather than POSIX mandating it.
>
> as a comparison, bash/ksh/tcsh/zsh/busybox[ash] all behave the way my patch
> updates dash to operate ... i would test more shells, but these tend to be the
> standards that everyone compares against.  i can't see people writing scripts
> that only work under dash either.
>
>> In any case, scripts that rely on escape codes like this are
>> simply broken and should either be fixed to use printf or just
>> run with #!/bin/bash.
>
> they're relying on these escape codes not being interpreted as escape codes
> (which every other shell appears to do), not the other way around

Scripts that rely on a certain interpretation of "echo '\1'" are broken 
regardless of how dash behaves; but that said, since POSIX doesn't 
require dash's current behavior, and since the proposed patch makes dash 
both smaller and more like other shells in treating it as an extension 
that means a literal 1 rather than an octal escape, I would be in favor 
of making the change in dash.

-- 
Eric Blake   eblake@HIDDEN    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




Acknowledgement sent to Eric Blake <eblake@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-libtool@HIDDEN. Full text available.
Report forwarded to bug-libtool@HIDDEN:
bug#9916; Package libtool. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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