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

Previous Next

Package: libtool;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Mon, 31 Oct 2011 13:16:01 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 9916 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-libtool <at> gnu.org:
bug#9916; Package libtool. (Mon, 31 Oct 2011 13:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake <at> redhat.com>:
New bug report received and forwarded. Copy sent to bug-libtool <at> gnu.org. (Mon, 31 Oct 2011 13:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Mike Frysinger <vapier <at> gentoo.org>
Cc: Herbert Xu <herbert <at> gondor.hengli.com.au>, dash <at> vger.kernel.org,
	bug-libtool <at> gnu.org
Subject: Re: [PATCH] echo: fix octal escaping with \1...\7
Date: Mon, 31 Oct 2011 07:12:43 -0600
[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 <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




Information forwarded to bug-libtool <at> gnu.org:
bug#9916; Package libtool. (Mon, 31 Oct 2011 18:43:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: Eric Blake <eblake <at> redhat.com>
Cc: Herbert Xu <herbert <at> gondor.hengli.com.au>, dash <at> vger.kernel.org,
	bug-libtool <at> gnu.org
Subject: Re: [PATCH] echo: fix octal escaping with \1...\7
Date: Mon, 31 Oct 2011 14:39:37 -0400
[Message part 1 (text/plain, inline)]
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).
> 
> 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 
applicable.  i might be wrong about the libtool side, but do know of at least 
one ax m4 file using it (which is what started this rat hole in the first 
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.
> >> 
> >> 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;

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
-mike
[signature.asc (application/pgp-signature, inline)]

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

Previous Next


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