[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#490605: debian-policy: please discourage the usage of echo -n, and echo in general



Package: debian-policy
Version: 3.0.8.1
Severity: wishlist

As demonstrated by the following trivia[1], and also mentioned by SUSv3, the 
echo built-in varies from implementation to implementation and thus should be 
discouraged.

8<---trivia-starts-here--->8
$ ./echo-trivia.sh
++ bash
+ o='Foo:\n\tI do not like bar!!\n\nBar:\n\tI do not like you either'
+ set +x
++ dash
+ o='Foo:
        I do not like bar!!

Bar:
        I do not like you either'
+ set +x
++ ksh
+ o='Foo:\n\tI do not like bar!!\n\nBar:\n\tI do not like you either'
+ set +x
++ zsh
+ o='Foo:
        I do not like bar!!

Bar:
        I do not like you either'
+ set +x
++ posh
+ o='Foo:
        I do not like bar!!

Bar:
        I do not like you either'
+ set +x
++ pdksh
+ o='Foo:
        I do not like bar!!

Bar:
        I do not like you either'
+ set +x
++ mksh
+ o='Foo:
        I do not like bar!!

Bar:
        I do not like you either'
+ set +x
++ busybox sh
+ o='Foo:\n\tI do not like bar!!\n\nBar:\n\tI do not like you either'
+ set +x
==Trivia results==
Shells tested: 8
Shells expandind backslashes: 5
/bin/echo does NOT expand
8<---trivia-ends-here--->8

Additionally, the usage of echo -n should also be discouraged because it may 
not help stressing the idea of echo not being portable.

Finally, completely OT but I don't believe it warrants yet another bug report, 
the following line should also mention the [ built-in and not just test:

> test, if implemented as a shell built-in, must support -a and -o as binary
> logical operators.


[1] The script basically prints some text with 'echo' which containing 
backslashes and checks whether the backslashes were expanded or not.

Kind regards,
-- 
Atomo64 - Raphael

Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: