If you were on a POSIX certified platform with UNIX branding, echo
did handle \c
by default.
This applies to Solaris, AIX, HP-UX and Apple.
Apple even uses bash
to support this echo behavior, but you need a specific compile option to make bash
compliant by default. This compile option for bash
is used for MacOS and for Solaris. So peole may be confused when they realise that bash
behaves different on a POSIX certified platform,
Remember: GNU
reads GNU is not UNIX.... many GNU tools are not POSIX compliant or not POSIX compliant by default. So be careful when you are not on a certified platform.
BTW: You may get the POSIX branding for small embedded platforms even when you do not support echo \c
, but for a UNIX
branding, you need to support all XSI
extensions to POSIX. Linux does not support most of the XSI
extensions. Many Linux distros e.g. use dash
as the default shell and dash
id definitely not compliant, e.g. because it does not support multi byte characters.
type -a echo
. Usually, you will have a shell built-in calledecho
provided by your shell in addition to/usr/bin/echo
which would have the flags you are looking for. The shell built-in usually supersedes the installed program. – GracefulRestart Feb 04 '20 at 20:44-n
and requires-e
to regognise\c
$ /bin/echo --version
echo (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
– Jasen Feb 04 '20 at 20:53echo
? Since you are mentioning GNU: notes about POSIX compatibility can be found ininfo coreutils echo
; they are not included inman echo
. – fra-san Feb 04 '20 at 20:59If the ‘POSIXLY_CORRECT’ environment variable is set,
... I think that answers my question. – Jasen Feb 04 '20 at 21:02printf
instead ofecho
. – Andrew Henle Feb 04 '20 at 21:09POSIXLY_CORRECT
in some cases makes GNU software more POSIX compliant, but only in rare cases fully compliant.bash
neither becomes fully POSIX compliant by this environment, nor by callingset -o posix
. You need a special compile option. At runtime, the switch is hidden undershopt
. – schily Feb 05 '20 at 08:58"frame" as in HTML - because I can't link to the whole page as I see it. – Jasen Feb 05 '20 at 09:08