Xref: utzoo comp.unix.questions:15078 comp.bugs.sys5:1042 comp.unix.microport:3597 Path: utzoo!attcan!uunet!mcvax!aeb From: aeb@cwi.nl (Andries Brouwer) Newsgroups: comp.unix.questions,comp.bugs.sys5,comp.unix.microport Subject: Re: ksh and sh Message-ID: <8282@boring.cwi.nl> Date: 20 Jul 89 21:23:26 GMT References: <372@trevan.UUCP> <8272@boring.cwi.nl> <11900@ulysses.homer.nj.att.com> Organization: CWI, Amsterdam Lines: 60 In article <11900@ulysses.homer.nj.att.com> ekrell@hector.UUCP (Eduardo Krell) writes: >In article <8272@boring.cwi.nl> aeb@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@cwi.nl