Subject: Re: CVS commit: basesrc/bin/ksh
To: Joerg Klemenz <>
From: Simon J. Gerraty <>
List: tech-userlevel
Date: 10/03/2002 15:26:40
>Since we are exchanging tips now I'll give you mine to. I put this in
>/etc/profile to load /etc/kshrc and $HOME/.kshrc if exists

>if (echo $0|grep -q ksh)
>    ... ksh stuff

Eek!  What's wrong with:

case /$0 in
*/ksh|*/-ksh) # we're ksh - yay!

avoids any fork/exec

>Still can't tell the difference between pdksh and ksh.

That's the whole point.  Well actually you can.  The
following is from my /etc/ksh.kshrc (bash users can set
KSH_VERSION=BASH in .bashrc):

		# the PD ksh is not 100% compatible
		case "$KSH_VERSION" in
		BASH)	;;
		*PD*)	# PD ksh
			case "$KSH_VERSION" in
			*5.*)	cdhist=ksh.cdhist
			case "$TERM" in
				# bind arrow keys
				bind '^[['=prefix-2
				bind '^XA'=up-history
				bind '^XB'=down-history
				bind '^XC'=forward-char
				bind '^XD'=backward-char
		*)	# real ksh ?
			set -o trackall
			case "$TERM" in
				# Kevin Gallagher in comp.emacs!
				alias	 __A= # up arrow
				alias	 __B= # down arrow
				alias	 __C= # right arrow
				alias	 __D= # left arrow

>All of this hacks are only needed because of ksh's lack of a "real" rc

Please keep in mind that the folk that wrote ksh aimed to be compatible with
sh, and IMHO did it right.  That bash and zsh screw things up is orthogonal.

>To make things even worse, there's no way that I know of to load
>defaults for non-interactive non-logged-in shells. The retarded $ENV
>construct assumes that the user is logged in when he starts a
>non-interactive shell.

How is this any different to /bin/sh ? 

>But many a script is run from cron or at and there is no way to force
>the loading of any defaults or even a PATH.

That's a bug in the shell script not the shell.

>All of that can be fixed, though. ksh is basically OK
>I guess I have to write that maintainer now...

Don't expect him to agree to change it in ways that would make it not 
compatible with ksh though.