2019-08-14 09:28:22 -0700, Kaz Kylheku (Coreutils):
[...]
> According to POSIX, echo doesn't take options. It is specified
> that "Implementations shall not support any options."
> (We have options, though,  so things are complicated.)
[...]

The POSIX specification of "echo" is going to change in a future
version. See: http://austingroupbugs.net/view.php?id=1222
and http://austingroupbugs.net/view.php?id=1222#c4375 for the
accepted new text.

In short, except when they implement the XSI option (which they
need to to claim the UNIX trademark) implementations are going to
be allowed to support a "-e", "-n" or "-E" option (but still not
"--"/"-" to mark the end of option) and their behaviour will
still be unspecified if any argument contains a backslash
character (in practice, most implementations also fail if those
arguments contain a multibyte character whose encoding contains
byte 0x5c, which happens to be the ASCII encoding of backslash)

Implementations that support an end of option marker include the
"echo" builtin of zsh ("-", formerly "--"), fish ("--"), Byron
Rakitzis clone of "rc" for Unix ("--") and its derivatives (es,
akanga).

With GNU "echo" (and GNU "env"), you can output "-n" or
arbitrary $data with:

env -u POSIXLY_CORRECT echo -En "$data
"

-- 
Stephane


Reply via email to