[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

On Sat, 12 Jul 2008, Raphael Geissert wrote:
> Package: debian-policy
> Version:
> 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.

Well, you just proved that you can't rely on correct interpretation
of special escaped characters and that's true. It's not a reason
to discourage echo or echo -n in general though. That would be ridiculous
given how frequently it's used.

But it would be nice to remember that printf "" must be used if you want
to reliably use escaped characters. But here you must take care to
use "%s" for each variable expansion:

echo "a $var\n b"
printf "a %s\n b\n" "$var"

Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :

Reply to: