[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Paolo Bonzini
Subject: Re: AT_DATA and AS_ECHO_N
Date: Wed, 29 Jul 2009 23:06:05 +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

   New applications which are not aiming at portability should use
   `printf' instead of `echo'.  M4sh provides the `AS_ECHO' and
   `AS_ECHO_N' macros, which choose between `echo -n' on
   implementations where that works, `printf' if it is available, or
   other creative tricks in order to work around the above problems.

Shouldn't the entry for printf mention this portability shortcoming of
printf as well?

Also, I find the first sentence above confusing.  Why is printf
recommended if not for portability?

Because it is true echo is not safe (it may eat the beginning of your output), but it is a mess to find a way to print that is also fast (i.e. possible it is a builtin). It may be print -r, echo --, echo -n, whatever. If you just use printf %s\n you are done, but you lose a tiny bit of portability. If you strive for portability at all costs, and do not use M4sh, you can look at other solutions.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]