Subject: Re: /bin/sh fixes to make printf a builtin and 'fix' echo
To: None <david@l8s.co.uk>
From: Ben Harris <bjharris@chiark.greenend.org.uk>
List: current-users
Date: 06/12/2002 11:57:04
[ Excuse me -- my fingers got confused and sent this to tech-kern the first
  time... ]

In article <20020611234528.H411@snowdrop.l8s.co.uk> you write:
>On Tue, Jun 11, 2002 at 04:39:25PM +0100, Ben Harris wrote:
>> In article <20020611140857.G411@snowdrop.l8s.co.uk> you write:
>> >options.h: Make 'V' and 'E' (vi and emacs) mutually exclusive,
>> >	Add new options '-o posix' and '-o SuS'
>> 
>> Ugh.  I'm strongly opposed to having to set options in order to get
>> standards conformance, not least because conformant applications can
>> probably do something that will turn the option off (e.g. invoking a new
>> instance of "sh" after clearing the environment).
>
>yes - the trouble is that doing anything else breaks compatibility
>with existing systems.

"-e" is undocumented.  It seems to me that breaking an undocumented and
non-standard feature is preferable to breaking conforming scripts.

>OTOH even to write C that is XPG4 (say) conformant requires
>defining thinks like (I can't remember the exact defines)
>#define _XPG4_SOURCE_1234
>in all the source files in order to get the header files to guarantee
>to generate the correct data....

There's no equivalent for shell scripts.  I think the nearest approximation
is what Solaris does, where the PATH used by conforming applications is
different from the normal system PATH, so they get the conforming utilities
from /usr/xpg4/bin rather than elsewhere.

>Still looks like at least two variants are required though!

Only if you believe that -e is still required.  My opinion is that anyone
using -e is depending on undocumented, non-standard behaviour, and deserves
very little sympathy if it stops working.

>There may also be other places where the posix behaviour, SuS
>behaviour and netbsd behaviour differ.

All versions of SUS explicitly defer to POSIX, so anything that's
SUS-conforming is also POSIX-conforming (at the right version).  Thus, the
only problem is that NetBSD's historic behaviour might conflict with one or
both standards.  Conflicts with SUS don't bother me much, since we've always
had a policy of ignoring Spec 1170, and SUS is a descendant of that. 
Conflicts with POSIX should, I feel, generally be resolved in favour of
POSIX, unless POSIX is obviously being stupid (as it was with "echo" before
I got it fixed).

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>