Understanding the Bourne Shell (was Re: Finding the last arg)

Brandon S. Allbery KB8JRR allbery at NCoast.ORG
Fri Jan 11 14:54:16 AEST 1991


As quoted from <1033 at mwtech.UUCP> by martin at mwtech.UUCP (Martin Weitzel):
+---------------
| In some sense, this are the "laws of nature" as derived from observing
| the shell's behaviour. As the shell is not really nature but the outcome
| of the thoughts of some human beeing, we could of course complain now
| that this is "illogical" (compared to our sense logic!) or that there
| are "too many exceptions" and that it could be simplified with fewer,
| but more general rules.
| 
| But when thinking how to smoothen things out by using fewer rules, we
| often do not recognize all the consequences that this would have.
+---------------

There is one other problem.  I daresay it would be possible to make Bourne
shell syntax a bit more "regular" by using a yacc grammar.  THIS WON'T WORK!
At least, not without making the shell much less useful --- yacc (or other
parser generators) grammars are not designed for interaction.  In order to
do interaction *well*, the shell needs to be able to have at least some idea
of what is going on *without* having read an entire complex command (read
"if/while/for/case/etc.").  I've tried writing a yacc grammar that does this
kind of thing in a graceful manner; I ended up using context-sensitive hacks,
which I dislike in otherwise simple parsers.  This is also why csh is not
actually like C --- C can depend on the parser collecting statements for it,
but csh is primarily designed for interactive use and therefore must be able
to keep track of what's going on incrementally.

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery at NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY



More information about the Comp.unix.shell mailing list