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

LFS Trac trac at linuxfromscratch.org
Sun May 9 22:02:25 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 bdubbs@…):

 Replying to [comment:5 matthew@…]:

 > 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.

 We do that now.  We only use /bin/echo if the test for arguments fails.
 For the default LFS install, the arguments do not fail and the builtin is
 used.


 > 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.

 Of course csh and tcsh are not compatible with our scripts in general,
 even though they do supply an echo builtin.  If anyone changes the default
 /bin/sh->bash link in an LFS system to *anyhting* else, I'd think it would
 be up to that user to check the bootscripts.

 > 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 Bash.

 The portability issue is covered now.  The speed of the scripts is not a
 noticeable issue.  Recommend closing as wontfix.

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



More information about the lfs-book mailing list