Bourne shell modifications, past and future

BALDWIN mike at whuxl.UUCP
Tue Nov 26 10:42:58 AEST 1985


> >My main problem with SysV's version of Bourne Shell is that functions
> >don't stick around in a new invocation of the shell.  In Berkley a
> >.cshrc is executed when ever a new shell is involked keeping the alias
> >around.  Korn shell fixed that by providing an enviornment variable,
> >ENV which contains the name of a file to be executed whenever a new shell
> >is involked.  Also in Korn shell, he provides BOTH aliasing and functions.

I think providing *both* aliasing and functions is a misfeature!  Why have
two inconsistent ways of doing the same thing???

> >Aliasing is faster, but functions are more complex.  [robertson]

I can't believe that aliases are so much faster that it warrants having
both schemes around.  After all, they are both done in the shell without
forking, and the fork/exec is the time-waster.

> ksh functions can also be exported.  [magill]

But not *really* exported; they only get exported to shell files spawned
directly from the ksh.  I.e., the functions don't go into the "real"
environment like in V8 so a ksh escape from vi won't have the exported
functions in it.  You need to use $ENV (aka .cshrc) in this case.  The
SVR2 shell functions are implicitly exported in this way (to *direct*
descendants).

"Real" exported functions ala V8 are very nice.  However, something like
$ENV can still be useful for things like setting certain options for
all invoked shell (e.g., set -au) or having the prompt show the level
(PS1=">$PS1").  The only way to do these things is with $ENV.

Back to my first point:  please don't implement something 2 or 3 times
in different ways!  Functions subsume aliases very nicely, so chuck
aliases!  Don't have funny % sequences in prompt strings when `uname`
or `pwd` will work fine.  If speed is the problem, then OK, speed it
up, but don't reimplement it unless there's an obviously better way
to do things.  I.e., if pwd is slow, build pwd into the shell instead
of adding a $PWD or $cwd variable.  However, instead of building in fd2
(remember fd2?), extend redirection to include file descriptors.
-- 
						Michael Baldwin
						{at&t}!whuxl!mike



More information about the Comp.unix mailing list