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

Re: Bug in bash

On Fri, Sep 28, 2001 at 06:20:51PM -0400, Bruce Jackson wrote:
> Jens Ruehmkorf wrote:
> > On Fri, 28 Sep 2001, Bruce Jackson wrote:
> >>If I do the following:  echo "bob\n" the output is:
> >>bob\n
> > 
> > $ echo "bob\n"
> > bob\n
> > $ echo -e "bob\n"
> > bob
> > 
> > See bash(1), do "help echo" inside bash. Ask debian-user for help.
> But, why is there a difference between the behaviour of bash under 
> Linux, HP-UX, and Solaris?  The protability of scripts is the problem.

Have a look at the autoconf info documentation, under 'Limitations of

     The simple `echo' is probably the most surprising source of
     portability troubles.  It is not possible to use `echo' portably
     unless both options and escape sequences are omitted.  New
     applications which are not aiming at portability should use
     `printf' instead of `echo'.


     Do not use backslashes in the arguments, as there is no consensus
     on their handling.  On `echo '\n' | wc -l', the `sh' of Digital
     Unix 4.0, MIPS RISC/OS 4.52, answer 2, but the Solaris' `sh', Bash
     and Zsh (in `sh' emulation mode) report 1.  Please note that the
     problem is truly `echo': all the shells understand `'\n'' as the
     string composed of a backslash and an `n'.

Colin Watson                                  [cjwatson@flatline.org.uk]

Reply to: