What's happening here :
$ echo $SHELL /bin/bash $ echo -e "foo" foo $ which echo /bin/echo $ /bin/echo -e "foo" -e foo
The last output is expected to be "foo", like when using echo
directly.
What's happening here :
$ echo $SHELL /bin/bash $ echo -e "foo" foo $ which echo /bin/echo $ /bin/echo -e "foo" -e foo
The last output is expected to be "foo", like when using echo
directly.
/bin/echo
is a program, and it's different from the Bash built-in echo
command.
According to the POSIX standard, echo
should not take any arguments. The Bash echo
command doesn't follow this standard, and the GNU Coreutils version doesn't either. Other versions may be more strict.
Try to find out what version /bin/echo
is by calling it with the --version
flag or see if it gives you some help with the --help
flag.
Also, man which
shows this:
which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell.
Bash is not strictly POSIX-conformant so the return value of which
may differ (and it does in this case because of the echo
built-in).
For further reading, see the answers to echo outputs -e parameter in bash scripts. How can I prevent this?