[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: echo kommando
From: |
Eric Blake |
Subject: |
Re: echo kommando |
Date: |
Thu, 22 Dec 2005 21:55:45 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to James Youngman on 12/22/2005 2:17 PM:
>>
>>z.B.
>>TESTVARIABLE="-n"
>>echo -n $TESTVARIABLE
Sorry that I don't speak German, but I agree that printf is more portable
than echo. However, I do think there is a bug here:
$ _POSIX2_VERSION=200112 POSIXLY_CORRECT=1 /bin/echo -n 'a\tb' | od -c
0000000 a \ t b
0000004
According to the POSIX 2001 standard,
http://www.opengroup.org/onlinepubs/009695399/nframe.html, "On
XSI-conformant systems, if the first operand is -n, it shall be treated as
a string, not an option. The following character sequences shall be
recognized on XSI-conformant systems within any of the arguments".
Therefore, when _POSIX2_VERSION selects the 2001 standard, and
POSIXLY_CORRECT is turned on, the above example should have output
"-n<space>a<tab>b<newline>" rather than "a\tb", as in:
$ printf -- '-n a\tb\n' |od -c
0000000 - n a \t b \n
0000007
It looks like the builtin bash echo has the same misbehavior on systems
desiring to be XSI conformant.
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDq4NQ84KuGfSFAYARAkfxAKC+5RvjghqqroeLMW6kOGlA5xRNWgCdFLdE
UJCh01xlUNEVxwVqjuvmS14=
=yKcM
-----END PGP SIGNATURE-----