Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site gatech.CSNET Path: utzoo!watmath!clyde!cbosgd!gatech!arnold From: arnold@gatech.CSNET (Arnold Robbins) Newsgroups: net.unix,net.unix-wizards Subject: Re: Bourne shell modifications, past and future (long) Message-ID: <1997@gatech.CSNET> Date: Tue, 19-Nov-85 13:50:57 EST Article-I.D.: gatech.1997 Posted: Tue Nov 19 13:50:57 1985 Date-Received: Wed, 20-Nov-85 08:33:05 EST References: <1943@gatech.CSNET> <10@druri.UUCP> <21@pixdoc.UUCP> <3@bbncc5.UUCP> <3328@brl-tgr.ARPA> <10@pixutl.UUCP> Reply-To: arnold@gatech.UUCP (Arnold Robbins) Organization: The Bill the Cat Fan Club Lines: 46 Xref: watmath net.unix:6295 net.unix-wizards:15783 Key: >>> unknown >> Doug Gwyn > Chris Bertin In article <10@pixutl.UUCP> chris@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@gatech ARPA: arnold%gatech.csnet@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.