Subject: Re: echo weirdness
To: None <current-users@NetBSD.org>
From: David Laight <david@l8s.co.uk>
List: current-users
Date: 02/18/2004 00:04:08
On Tue, Feb 17, 2004 at 04:44:18PM +0100, Christian Biere wrote:
> Hi,
> 
> the builtin echo of /bin/sh understands the parameter '-e' to enable
> printf-style escape codes. This isn't documented anywhere AFAICS. The
> manpage refers to echo(1) but /bin/echo doesn't understand '-e'. Isn't
> this a doc-bug? Also /bin/sh doesn't use getopt-style parsing for the
> arguments of echo so that "echo -n -e blah" has different output as
> "echo -ne blah". I wonder whether that's a bug or intentional. It
> should be documented in either case, IMHO.

Do not put your fingers into a bag of worms - they bite :-)

Basically echo is required to be broken for compatibility.
In particular BSD echo and SYSV echo are irreparably incompatible, and
neither is (or can be made) getopt compatible.

Fot portability use printf(1) - which is a builtin in netbsd /bin/sh.

	David

-- 
David Laight: david@l8s.co.uk