dash built-in echo expands \nnn sequences

Asked by Mauricio Villegas on 2011-07-14

Binary package hint: dash

dash 0.5.5.1-7.2ubuntu1
Ubuntu 11.04
Linux eclipse 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

When running the following I get:

$ dash -c "echo 'hello\7there'"
hellothere

Apparently the '\7' gets expanded to ascii character 7 (bell). In other shells this does not happen:

$ bash -c "echo 'hello\7there'"
hello\7there
$ ksh -c "echo 'hello\7there'"
hello\7there
$ zsh -c "echo 'hello\7there'"
hello\7there

Is this supposed to be the correct behavior or is it a bug?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu dash Edit question
Assignee:
No assignee Edit question
Solved by:
Mauricio Villegas
Solved:
2011-07-15
Last query:
2011-07-15
Last reply:

I had it all wrong, it is the echo the one that expands the '\7'. This can be resolved by using printf

$ dash -c "printf '%s\n' 'hello\7there'"
hello\7there

Then is "echo" not portable?

see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=550399

solved