ksh and sh

Andries Brouwer aeb at cwi.nl
Fri Jul 21 07:23:26 AEST 1989


In article <11900 at ulysses.homer.nj.att.com> ekrell at hector.UUCP (Eduardo Krell) writes:
>In article <8272 at boring.cwi.nl> aeb at cwi.nl (Andries Brouwer) writes:
>
>>I have been bitten several times by the fact that ksh does not
>>search the PATH for each command, but remembers where the command
>>was. (I.e., some commands, sometimes all commands,
>>are tracked aliases. There is an option to make all commands
>>tracked aliases, but none to switch off this `feature'.)
>
>I believe all you have to do is change the value of $PATH to
>force ksh into unbinding all the tracked aliases. I use
>
>PATH=$PATH
>
>which doesn't change the value of $PATH, but makes ksh throw
>away the old bindings.

Yes, I am well aware of that.

[But note that tracked aliases do not cease to be tracked, so the
only way to get rid of tracked aliases is to say
	unalias grep; unalias cc; ...
in my profile, listing all tracked aliases. However, which names
are tracked aliases is not documented anywhere, so one needs the
source to do this.]

The problem is not getting ksh to execute any particular command,
the problem is recognizing that there might be a problem.

The problem is just that ksh does the wrong thing, and hence
is not compatible with sh.
Moreover, ksh quite unexpectedly does the wrong thing.

When I did timing tests on two versions of grep I wasted
my time because ksh ran the wrong grep.
When I constructed a new version of nohup and tested it with
`nohup pwd', I was very surprised getting error messages from
the line printer daemon. But, you see, ksh thought
that nohup was the standard nohup (while in fact
it was a Bourne shell script), and expanded `pwd'
into `print - $PWD', and thus my shell script subsequently
ran print, calling lpr on a directory.
(Yes, after the expansion ksh ran my nohup, not the standard one.)

In each case you tell me that I could have avoided problems
by saying PATH=$PATH, but with sh I have no problems, and need
not avoid them.
Thus, the `tracked aliases' misfeature of ksh
burdens my memory with yet another thing to worry about.
Since I otherwise am quite happy with ksh, I hacked the source
and just removed all tracked alias stuff, creating my private,
more reliable ksh.

These tracked aliases were not invented because they are useful,
but because they save a few milliseconds on each command that I
give. However, one hour of wasted time wipes out the milliseconds
gained in many years. Such a feature can best be deleted altogether,
or, when people insist, given as an option, turned off by default.
-- 
      Andries Brouwer -- CWI, Amsterdam -- uunet!mcvax!aeb -- aeb at cwi.nl



More information about the Comp.unix.microport mailing list