Subject: bin/639: /bin/sh not ksh compatable, but processes $ENV
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Simon J. Gerraty <sjg@zen.void.oz.au>
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
>Organization:
Zen programing...
>Release:        1.0
>Environment:
	
System: NetBSD zen.void.oz.au 1.0 NetBSD 1.0 (ZEN) #5: Thu Dec 1 09:06:16 EST 1994 root@zen.void.oz.au:/e0/usr.src/sys/arch/i386/compile/ZEN i386


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

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

>How-To-Repeat:
try the following with /bin/sh
:
HOSTNAME=zen.void.oz.au
if [ x$RANDOM != x$RANDOM ]; then
	# ksh
	HOST=${HOSTNAME%%.*}
else
	# !ksh
	HOST=`IFS=.; set $HOSTNAME; echo $1`
fi
echo "$HOSTNAME -> $HOST"
>Fix:
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.
>Audit-Trail:
>Unformatted: