Subject: Re: discrepency beteen /bin/echo and builtin echo of /bin/sh
To: <>
From: David Laight <>
List: current-users
Date: 06/09/2002 20:11:09
On Sun, Jun 09, 2002 at 11:06:38AM -0700, Greywolf wrote:
> On Sun, 9 Jun 2002, David Laight wrote:
> greywolf> <cringe>And this is why, exactly?</cringe>
> # Because it (alomost certainly) doesn't break any existing scripts.....
> According to ksh, anyway (which is its own abomination IMHO).
> The world is not ksh.  sh remains the most portable.  Any programs which
> assume otherwise in their #! line deserve exactly what they get.

Actually having #! <some_binary> is fine!
The PROBLEM are those scripts that start #! /bin/sh and expect
behaviour that isn't part of the traditional bourne shell.
(this include netbsd's
Systems that install shells into /bin/sh which are nothing
like a bourne shell ought to be deleted (bash is a particularly
good example of a bad sh).

There is the slight unfortunate problem that the SuS requires
that sh behave (to some extent) like ksh.
(Posix probably allows you to do anything that any system that
wanted to be called 'posix compiant' actually did at the time
the standard was written - whether or not it was sensible.)

I do (usually) try to write scripts that that a 'proper'
bourne sh (eg the solaris one) will run.  Sometimes it gets
a bit lively and I resort to ksh in order to do ${x%%y} etc.
It is possibe to get sh to do something equivalent (typically
using eval and case) - using expr (not a builtin) slows things
down too much).

Todays little script (you might use awk - I just use sh!)
used printf - and is particularly sluggish because of the
fork/exec.  Inside nexted loops running any non-builtin
is a complete no no.

(maybe both printf and expr should be builtin?)


David Laight: