bug-autoconf
[Top][All Lists]
Advanced

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

Re: AT_DATA and AS_ECHO_N


From: Joel E. Denny
Subject: Re: AT_DATA and AS_ECHO_N
Date: Thu, 30 Jul 2009 09:47:04 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Thu, 30 Jul 2009, Paolo Bonzini wrote:

> Thanks, I'm committing it with this additional rewording..

Thanks.

> > +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 and
> easier to use than @command{echo}.  Thus, scripts where portability is not a
> major concern should use @command{printf '%s\n'} instead of @command{echo},

printf's lack of availability as a builtin (rather than lack of 
availability altogether) on some systems doesn't imply lack of portability 
to me... unless you mean lack of portability of speed.  Can this be 
clarified?  Here are two possible wordings.  I'm not sure which is more 
correct:

  While @command{printf} is not a builtin on all systems, it is safer and 
  easier to use than @command{echo}.  Thus, when portability of a script's 
  speed is not a major concern, the script should use @command{printf 
  '%s\n'} instead of @command{echo},

or, it might be easier to just let printf's entry clarify this point:

  While @command{printf} is not fully portable (@pxref{printf, , 
  Limitations of Shell Builtins}), it is safer and easier 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.




reply via email to

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