[petsc-dev] printf versus echo -e/-n

Satish Balay balay at mcs.anl.gov
Sat Oct 20 14:35:56 CDT 2012


ok pushed http://petsc.cs.iit.edu/petsc/petsc-dev/rev/2addaed2f3be

satish

On Sat, 20 Oct 2012, Jed Brown wrote:

> On Sat, Oct 20, 2012 at 11:28 AM, Satish Balay <balay at mcs.anl.gov> wrote:
> 
> > printf is more portable. It should always be preferred over echo -e. If
> > targeting bash/zsh/ksh
> > <<<<
> >
> > is printf portable with  bourne shell aswell?
> >
> 
> You have chosen to split the quote in a very peculiar way. Putting the
> sentences on separate lines should help clarify
> 
> *'''
> printf is more portable.
> 
> It should always be preferred over echo -e.
> 
> If targeting bash/zsh/ksh specifically, echo $'...' is also ok.
> 
> If targeting zsh or ksh specifically, print is ok.*
> *'''*
> 
> Look at the table here: http://www.in-ulm.de/~mascheck/various/echo+printf/
> There hasn't been an OS without printf since the 1980s.
> 
> "New applications are encouraged to use printf instead of echo."
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html#tag_20_37_16
> 
> 
> > Because thats what we target.
> >
> > I don't really need '-e' there. Instead of
> >
> > >>>
> > mpif90 -show: ln -s /sandbox/petsc/software/mpich-1.2.7p1/include/mpif.h
> > mpif.h
> > ifort -L/sandbox/petsc/software/mpich-1.2.7p1/lib -lmpichf90 -lmpich
> > -lpthread -lrt
> > rm -f mpif.h
> > <<<
> > I can do with:
> >
> > >>>
> > mpif90 -show: ln -s /sandbox/petsc/software/mpich-1.2.7p1/include/mpif.h
> > mpif.h (newline) ifort -L/sandbox/petsc/software/mpich-1.2.7p1/lib
> > -lmpichf90 -lmpich -lpthread -lrt (newline) rm -f mpif.h
> > <<<
> >
> 




More information about the petsc-dev mailing list