Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!tut.cis.ohio-state.edu!VAX1.CC.UAKRON.EDU!mcs.kent.edu!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.unix.shell Subject: Re: Understanding the Bourne Shell (was Re: Finding the last arg) Message-ID: <1991Jan11.035416.18772@NCoast.ORG> Date: 11 Jan 91 03:54:16 GMT References: <1020@mwtech.UUCP> <443@minya.UUCP> <1033@mwtech.UUCP> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.unix.shell Organization: North Coast Computer Resources (ncoast) Lines: 32 As quoted from <1033@mwtech.UUCP> by martin@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@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