Bourne shell modifications, past and future (long)
Arnold Robbins
arnold at gatech.CSNET
Wed Nov 20 04:50:57 AEST 1985
Key: >>> unknown >> Doug Gwyn > Chris Bertin
In article <10 at pixutl.UUCP> chris at pixutl.UUCP (chris) writes:
>>
>>> I think the most glaring difference between csh aliasing and
>>> sys5 bourne shell functions is that the latter looks up builtins first.
>>> This means you can't define functions that clash with shell commands.
>>> On the other hand shell functions have a MUCH better syntax. Why not
>>> move up the expansion of shell functions ahead of builtins at
>>> the expense of not having recursive functions.
>>
>> Very good question. My guess is that either (a) it was easier
>> to do it the other way, or (b) it would be considered a security
>> problem in restricted shells. Can DGK tell us why?
>
> The main implementation problem in having functions overrule builtins is
> that both builtins and functions share the same B-tree. If you wanted to
> have a function with the same name as a builtin, you would have to save
> it somewhere, add new flags, etc... all that adding overhead and
> complexity.
>
>
> Chris
Sorry Chris, but builtins (cd, test, etc.) have their own private table.
The S5R2 shell keeps it sorted for a quick binary search, earlier Bourne
shell's used a linear search that checked the first character, and then the
rest of the word.
It is shell functions and shell variables that share the same b-tree, and in
fact it would not be all that hard to have shell functions found first.
That is apparently what Rob Pike did for the 8th Edition shell. I may try
to implement the "builtin" built-in command he described, and put shell
functions first; that will come after everything else I'm working on is done.
Yet another Unix wizard defeated by the Bourne shell! :-) Just kidding Chris,
the changes you mailed to me have already been incorporated in what I'm
doing.
As I've said before, "Nuke the csh!"
--
Arnold Robbins
CSNET: arnold at gatech ARPA: arnold%gatech.csnet at csnet-relay.arpa
UUCP: { akgua, allegra, hplabs, ihnp4, seismo, ut-sally }!gatech!arnold
Real Unix hackers disdain wimpy languages like C and AWK in favor of /bin/sh.
More information about the Comp.unix.wizards
mailing list