Subject: Re: A shell gotcha
To: Simon J. Gerraty <sjg@frodo.dn.itg.telecom.com.au>
From: Greg A. Woods <woods@kuma.web.net>
List: current-users
Date: 04/18/1995 12:38:49
[ On Tue, April 18, 1995 at 14:05:03 (+1000), Simon J. Gerraty wrote: ]
> Subject: Re: A shell gotcha 
>
> Anyway the bottom line is that you cannot have any ksh specific
> syntax in ksh's startup file ($ENV).  This situation is ridiculous but
> blame POSIX...

I have been doing the following in my ~/.profile to selectively set $ENV
through a shell specific dot-login file, and as you can see I'm hoping
that ash doesn't take on $RANDOM as a feature!

I use my same .profile (and the other files it references) on all the
systems I use, including BSDI, NetBSD, SunOS-4, SysVr3, and SysVr4, and
of those I use either sh(1), ash(1), ksh(1), or sometimes bash(1) or
zsh(1), though I try to stay as far away from bash as possible.

[[ This is, of course, only a fragment of my .profile. ]]

# one thing we assume here is that PS1 will be set in .*login or $ENV
# depending on the shell.
#
if [ ${RANDOM:-0} -ne 0 ] ; then
	# TODO: try to remember why we don't trust this...
	SHELL=""
	[ -x $LOCAL/bin/ksh ] && export SHELL="$LOCAL/bin/ksh"
	[ -z "$SHELL" -a -x /usr/bin/ksh ] && export SHELL="/usr/bin/ksh"
	[ -z "$SHELL" -a -x /bin/ksh ] && export SHELL="/bin/ksh"
	if [ -r $HOME/.kshlogin ] ; then
		. $HOME/.kshlogin
	fi
elif [ `echo ~` = $HOME ] ; then
	# TODO: actually, maybe this should be a Posix shell environment...
	if [ -r $HOME/.ashlogin ] ; then
		. $HOME/.ashlogin
	fi
elif [ -r $HOME/.shlogin ] ; then
	if [ -r $HOME/.shlogin ] ; then
		. $HOME/.shlogin
		# TODO: maybe this should be done last?
		if [ -n "$ENV" ] ; then
			. $ENV
		else
			if [ "$LOGNAME" = root ] ; then
				PS1="[$TTYN]<$LOGNAME@$UUNAME> # "
			else
				PS1="[$TTYN]<$LOGNAME@$UUNAME> $ "
			fi
		fi
	fi
else
	if [ "$LOGNAME" = root ] ; then
		PS1="[$TTYN]<$LOGNAME@$UUNAME> # "
	else
		PS1="[$TTYN]<$LOGNAME@$UUNAME> $ "
	fi
fi


-- 
							Greg A. Woods

+1 416 443-1734			VE3TCP			robohack!woods
Planix, Inc. <woods@planix.com>; Secrets Of The Weird <woods@weird.com>