Subject: Re: /bin/sh fixes to make printf a builtin and 'fix' echo
To: None <tech-userlevel@NetBSD.ORG>
From: Greg A. Woods <>
List: tech-userlevel
Date: 06/14/2002 17:01:47
[ On Friday, June 14, 2002 at 21:19:02 (+0100), Ben Harris wrote: ]
> Subject: Re: /bin/sh fixes to make printf a builtin and 'fix' echo
> Is there really a significant body of existing scripts using "-e" as an
> option to echo?

I don't know, but it doesn't really matter.  If only one does then
ignoring an initial "-e" option is no skin off the implementor's back,
not out of compliance with 1003.2 (original), and will save the porter
the headache of having to immediately find an fix the problem.

> Excuse me, I've just had a small revelation.  Would you have any problem
> with an echo that swallowed -e if any of the arguments contained a
> backslash, and echoed it otherwise?  So:

That wouldn't be a problem per se, but that's strictly an implementation
choice w.r.t. 1003.2.  There's no harm in always eating '-e' is there?
How many scripts and programmers would expect "-e" to appear in the
output if it's the first command-line parameter?  I'll bet the number
isn't just close to zero, but that it is zero if we don't count people
who care deeply about standards of any sort.

> This would conform with all the versions of POSIX that I care about.

Always "eating" an intial '-e' conforms with all the versions of POSIX I
care about!  :-)

I guess the real question though is whether eating an initial "-e" iff
there are backslashes in other parameters is sufficient for programmers
and users who might encounter the fabled script using "-e".  It may be,
but that's a much harder question to be 100% certain about than just
always eating an initial "-e" since a script might always use "echo -e"
even when there are no backslashes, such as with ``echo -e $foo'', and
not always eating '-e' won't solve the problem at all in that case.

								Greg A. Woods

+1 416 218-0098;  <>;  <>;  <>
Planix, Inc. <>; VE3TCP; Secrets of the Weird <>