On 21/01/03 02:38, Greg Reagle wrote: > I am in the habit of using printf rather than echo because of the drawbacks > of echo as explained in > https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo. > For > echo relinking > specifically, it doesn't matter. For > echo recompiling $2.c > specifically, if $2 contains any characters that echo might interpret, it > might come out wrong.
echo is generally used much more often than printf in shell scripts, if not for anything else then for historic reasons. Any problems with characters which could be interpreted by echo can be avoided by simply not using such characters or strings in filenames, but limiting oneself to, for example, [A-Za-z0-9._-]+.. > They are educational messages for me because I am learning. This is not only a convention of Go, but also a much older convention of UNIX programs, to avoid output unless there is an error, in which case the output is made to stderr. This is not without reason. In UNIX, programs should ideally work with each other through piping, and their output can also be redirected to a file. I think Sergey's example is very good, as cc does not output anything, unless it has a warning or an error, in which case it also uses stderr. redo uses a similar philosophy, in contrast to GNU Make, which outputs whenever it enters a directory (for example). Best regards, Strahinya Radich