[LFS Trac] #2646: scripts should use printf instead of echo

LFS Trac trac at linuxfromscratch.org
Sun May 9 09:09:34 PDT 2010

#2646: scripts should use printf instead of echo
 Reporter:  tito_puentes  |       Owner:  lfs-book@…                   
     Type:  defect        |      Status:  new                          
 Priority:  low           |   Milestone:  6.7                          
Component:  Bootscripts   |     Version:  SVN                          
 Severity:  minor         |    Keywords:  echo printf POSIX            

Comment(by matthew@…):

 `printf' is generally preferred to `echo' for portability reasons.  See
 Builtins.html#echo for the various portability issues around using `echo'.

 In a default LFS install, bash provides both `printf' and `echo' as shell
 builtins so if we remove the '/bin/' prefix from our calls to echo then
 there's no speed difference at all between the two.

 From a quick google, bash provides both printf and echo as builtins, as
 does zsh.  csh, dash, ksh & tcsh all offer echo, but not printf.

 I've got a preference for portability over speed here; the slowdown caused
 by not using a shell builtin is probably going to be less noticeable than
 the portability issues if someone does decide to use a shell other than

Ticket URL: <http://wiki.linuxfromscratch.org/lfs/ticket/2646#comment:5>
LFS Trac <http://wiki.linuxfromscratch.org/lfs/>
Linux From Scratch: Your Distro, Your Rules.

More information about the lfs-book mailing list