4 ms·
That is true, but there are two caveats: 1. POSIX /bin/echo does not recognize any options other than "-n", and "-n" is "implementation-defined". [0] So you en
by BrandonM 15y ago
That is true, but there are two caveats:
1. POSIX /bin/echo does not recognize any options other than "-n", and "-n" is "implementation-defined". [0] So you end up right back at the same problem.
2. I highly recommend using built-ins where possible. Invoking /bin/echo instead of using echo involves copying a string into an argument vector, setting argc, loading /bin/echo, attaching std file descriptors, and forking. All of this to print a string to stdout.
It's much better to explicitly specify the behavior you want by invoking the appropriate interpreter, or to use /bin/sh while being sure to stick to POSIX-compliant functionality (e.g. printf).
[0] http://pubs.opengroup.org/onlinepubs/009695399/utilities/echo.html http://pubs.opengroup.org/onlinepubs/009695399/utilities/ech...