Subject: Re: make release abends with "*** Error code 1" SOLVED ERRATUM
To: None <netbsd-help@NetBSD.org>
From: Woodchuck <djv@bedford.net>
List: netbsd-help
Date: 01/22/2007 13:27:33
On Mon, 22 Jan 2007, I, Woodchuck, wrote:

> The first thing to do is bracket the interior of .kshrc with
> 
> 	if [ -o interactive ]; then
> 		. /etc/ksh.kshrc
> 		<other stuffs>
> 	fi

Alas, I thought I were done.  This recommendation does not work
on NetBSD, because 
	if [ -o <some shell state> ]
is bogus.  It is bogus because sh does not implement test/[ as
an internal, but has recourse to /bin/[.   So this line in a .kshrc
(or in any other sh script) is an error, generating an error message
on stdout, and causing an error return.  It is quite legal in ksh,
however.  It also works on a system that derives its sh from ksh,
which you can tell by looking for a hard link between /bin/sh and
/bin/ksh.  NetBSD's sh has a different provenance.  Merging the code
for sh and ksh is probably a low-priority project, or there may be
other valid objections to it.

Automatic execution of scripts by the two shells is not simple nor
easy to justify, and requires a diagram to understand.  See the man
pages for details. 

The rules for .kshrc and any script it sources remain simple: do
nothing that generates output to stdout or stderr, do nothing that
generates an error return in either ksh or sh, unless you handle
that return, exercise the error mode and reach your own conclusion.
I would also guard against function definitions, or any sort of ksh
extension, if one plans on ever executing a sh script of any
complexity.  A simple test is to try this
        echo ls | sh -e

and see what happens.  Adding the -x and -v switches to sh will help,
too.  Even though that sh is, according to the man pages, NOT an
interactive shell (its stdin is not a tty), it WILL execute ENV.
(I think.  It seems to.  I have a headache.)  Before going on in
that vein, I need to see the POSIX spec for sh(1) and ksh(1).
The man pages are not authoritive, and in fact dislaim authority
and completeness, as is proper.

Sorry for droning on, but I didn't want to leave a glaring boner in
the archives, particularly since it causes the same bug I am claiming
to have found and stomped.

Dave