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

Re: Prompting \n



T o n g wrote:
> T o n g wrote:
> > BTW, the reason that I gave up 'echo -e' was that it started to
> > mysteriously output that "-e " in front of the messages I wanted to show
> > in my /bin/sh scripts. I still haven't figure out why yet.
> 
> Oh, I forgot, I've already figured it out -- Now /bin/sh points to dash 
> (instead of bash previously):

Ah, yes, because 'echo -e' isn't portable.

> On NetBSD, it's the contrary: 

BSD uses 'echo -e' to print escape sequences and 'echo -n' to avoid
printing a newline.  System V uses 'echo' which always prints escape
sequences and ending a string with \c avoids printing a newline.
Which means that System V shells will always print -e or -n if it is
given as an option argument to echo.  This difference has been going
on for decades and neither side will change to match the other.  It is
why printf was created to avoid the problem.  Being a new command it
didn't have the difference history and is specified in the standards
as being required to comply on all systems.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: