Subject: Re: why do packages depend on coreutils?
To: Packages Technical List NetBSD Discussion <tech-pkg@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-pkg
Date: 10/17/2006 19:34:37
On Tue, 17 Oct 2006, David Laight wrote:
> IIRC posix failed to reconcile the difference between the BSD echo
> and the AT&T echo.  Largely because putting a foot in either camp
> would alienate the other and break too many existing scripts.
> 
> So POSIX leaves a lot of the output of echo undefined so that both
> the BSD and AT&T/SYSV forms are conformant.

Right.

Before printf(1) existed, scripts that cared used to detect whether "-n"
or "\c" was usable for suppressing the newline; set N='-n' and C='' for
one style, or N='' and C='\c' for the other style; then do {echo $N
"${string}$C"}.

Nowadays, I'd recommend using {printf "%s\n" "$string"} if you want a
newline, or {printf "%s" "$string"} if you don't.  Well, you can still
use {echo "$string"} if you want a newline and you can guarantee that
your string doesn't start with "-" or contain a backslash.

--apb (Alan Barrett)