Re: [BUGS] test failure in t4014-format-patch.sh with master

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

 



On 2008.04.17 08:44:07 -0700, Linus Torvalds wrote:
> 
> 
> On Thu, 17 Apr 2008, Björn Steinbrink wrote:
> > 
> > Debian has its own dash which is supposed to be a lightweight
> > alternative to bash and "for checking POSIX compliance of scripts"
> > (quote from the packages description). I don't happen to know off-hand
> > whether POSIX says that echo should default to -e, but dash seems to do
> > that:
> > 
> > $ dash
> > $ a="hello\nhi"
> > $ echo $a
> > hello
> > hi
> 
> Ahh. So that "echo" should just be replaced with a 'printf "%s\n"' 
> instead? 
> 
> We have a _lot_ of "echo"s though. I suspect the only ones we'd ever catch 
> are the ones explicitly tested for. I suspect that the dash echo is just 
> broken.

Wow, seems that "echo" in itself is "broken". According to POSIX[1]
backslashes induce implementation defined behaviour, and there seem to
be two historic versions of echo, one that knows about -n and one that
interprets escape sequences. So echo is totally non-portable unless you
avoid -n as well as backslashes. Ouch.

The POSIX docs, as well as random Google results, indeed recommend to
use printf instead. But that switch seems painful as well...

Björn

[1] http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux