|
From: | Paolo Bonzini |
Subject: | Re: AT_DATA and AS_ECHO_N |
Date: | Thu, 30 Jul 2009 14:58:26 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2 |
Thanks, I'm committing it with this additional rewording..
+While @command{printf} is not available on all systems, it is safer and +easier to use than @command{echo}. +Thus, new applications which are not aiming at portability should use address@hidden instead of @command{echo}. +When portability is important, M4sh provides the @code{AS_ECHO} and address@hidden macros, which choose between @samp{echo -n} on +implementations where that works, @command{printf} if it is available, +or other creative tricks in order to work around the above problems.
While @command{printf} is not a builtin on all systems, it is safer andeasier to use than @command{echo}. Thus, scripts where portability is not a major concern should use @command{printf '%s\n'} instead of @command{echo}, and @command{printf %s} instead of @command{echo -n}. For portable shell scripts it is suggested to use M4sh and its @code{AS_ECHO} and @code{AS_ECHO_N} macros, which choose between various implementations: @samp{echo} or @samp{print} where that works, @command{printf} if it is available, or other creative tricks in order to work around the above problems.
> address@hidden is not available on all systems.@command{printf} is not always a builtin; if not, every invocation would cause a fork and the consequent speed penalty.
[Prev in Thread] | Current Thread | [Next in Thread] |