Reputation: 645
The command
utility in Mac OS X which is at version 2.6.0 doesn't seem to honor the arguments passed in for the echo
command.
If this is a legit bug - can you kindly point me to the project page for this utility. Thanks!
$ command echo -e "activate\ndeactivate"
activate
deactivate
$ command echo -e "activate\ndeactivate"
-e activate\ndeactivate
$ command ls -al
total 3
drwxr-xr-x 13 siva staff 442 Sep 28 10:52 .
drwxr-xr-x 7 siva staff 238 Sep 19 14:21 ..
drwxr-xr-x 13 siva staff 442 Sep 28 10:52 .git
$ command ls -a1
.
..
.git
$ echo -e "activate\ndeactivate"
activate
deactivate
Upvotes: 2
Views: 87
Reputation: 295473
echo -e
is a nonstandard bash extension. Not only is it not required by the standard, it's not even allowed by the standard, which explicitly states that "Implementations shall not support any options".
bash breaks the standard by honoring -e
as an option (except when both posix
and xpg_echo
options are set, in which case it behaves identically to your external echo
command).
Thus, when you run the external echo
command provided by your OS vendor, it's an implementation compliant with http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html, and it responds to -e
by printing the string.
As a POSIX-compliant alternative to echo -e "$foo"
, use printf '%b\n' "$foo"
.
Upvotes: 5