Subject: bin/639: /bin/sh not ksh compatable, but processes $ENV
To: None <>
From: Simon J. Gerraty <>
List: netbsd-bugs
Date: 12/12/1994 04:50:05
>Number:         639
>Category:       bin
>Synopsis:       /bin/sh processed $ENV as does /bin/ksh, but sh can't handle it.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 12 04:50:03 1994
>Originator:     Simon J. Gerraty
Zen programing...
>Release:        1.0
System: NetBSD 1.0 NetBSD 1.0 (ZEN) #5: Thu Dec 1 09:06:16 EST 1994 i386

/bin/sh processes ksh's $ENV yet it cannot handle things ksh things
like ${HOSTNAME%%.*}, even protecting ksh specifics inside something

if [ x$RANDOM != x$RANDOM ]; then
	# ksh
gets a "Syntax error: Bad substitution" error.
Meaning that $ENV cannot contain any ksh specific syntax.

try the following with /bin/sh
if [ x$RANDOM != x$RANDOM ]; then
	# ksh
	# !ksh
	HOST=`IFS=.; set $HOSTNAME; echo $1`
echo "$HOSTNAME -> $HOST"
Remove all ksh magic from $ENV.
Pick a new variable name for /bin/sh
or, let /bin/sh not syntax check code inside if's that won't
be executed.