Bug 591492 - builtin echo -e does not handle \nnn octal escape unless its first digit is 0
Summary: builtin echo -e does not handle \nnn octal escape unless its first digit is 0
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash   
(Show other bugs)
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Roman Rakus
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-05-12 12:10 UTC by Denys Vlasenko
Modified: 2014-01-13 00:11 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-07-01 12:50:37 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Denys Vlasenko 2010-05-12 12:10:34 UTC
Description of problem:

builtin echo -e does not handle \nnn octal escape unless its first digit is 0.
Example:
echo -e '\44' prints: \44


Expected results:
echo -e '\44' should print the character with code 44 octal, that is, '$'


Version-Release number of selected component (if applicable):
bash --version
GNU bash, version 4.0.23(1)-release (x86_64-redhat-linux-gnu)
Older bash seems to be affected too:
bash --version
GNU bash, version 3.2.39(1)-release (i686-pc-linux-gnu)


Additional info:
echo from GNU coreutils 7.2 treats '\44' as '$'.
both bash builtin printf and coreutils' printf treat '\44' as '$'.
Other Unixes' manpages seem to indicate that their echo's handle non-0-prefixed escape sequences too - see, say, http://ss64.com/bash/echo.html, http://swoolley.org/man.cgi/echo

Comment 1 Roman Rakus 2010-05-12 13:20:35 UTC
So the bogus is echo from coreutils. See http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
Also, bash's echo works as documented - see man page of echo builtin.

Comment 2 Ondrej Vasik 2010-05-12 14:46:53 UTC
On bash 3.1.17(1) builtin echo does:
$ echo -e '\44'
$

GNU coreutils echo always supported \NNN format for octal character - it did not supported \0NNN until http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=97a6ce40ed4a34c9fb5eba5b50572f81bb839930 . This is documented in `info echo invocation` documentation. However - that's nonstandard thing, so bash builtin echo could choose to support only \0NNN octal format. 

It was changed between 3.1 and 3.2 by http://git.savannah.gnu.org/cgit/bash.git/diff/builtins/echo.def?id=0628567a28f3510f506ae46cb9b24b73a6d2dc5d 
for reference ...

Comment 3 Denys Vlasenko 2010-05-12 15:08:56 UTC
(In reply to comment #1)
> So the bogus is echo from coreutils. See
> http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
> Also, bash's echo works as documented - see man page of echo builtin.    

It's not like bash echo builtin does not support something on top of Open Group Base Specification. For example, that page doesn't document \e too, but \e works.

Comment 4 Roman Rakus 2010-07-01 12:50:37 UTC
Nevertheless, bash works as documented and there's not any rule to handle \nnn in echo. Use printf instead - what is recommend...


Note You need to log in before you can comment on or make changes to this bug.