Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!watmath!clyde!floyd!harpo!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.unix Subject: Re: Shell programming style -- a plea for better shell scripts Message-ID: <1718@rlgvax.UUCP> Date: Fri, 17-Feb-84 01:13:22 EST Article-I.D.: rlgvax.1718 Posted: Fri Feb 17 01:13:22 1984 Date-Received: Mon, 20-Feb-84 16:30:35 EST References: <5684@mcvax.UUCP> <226@teldata.UUCP> <239@teltone.UUCP> <363@hocda.UUCP> <3846@genrad.UUCP> <1204@pur-phy.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 56 A reply to several articles: 1) the #! /bin/csh -f construct is not only not portable because of the kernel change to run shell files being a Berkeleyism, but because the C shell isn't on all UNIX systems. The Bourne shell *is* on all UNIX systems worth talking about in this day and age. 2) The C shell resembles C about as much as the Bourne shell resembles Algol 68, so claims that the C shell is better than the Bourne shell because it looks more like the UNIX implementation language are bogus. 3) > Instead of case ... in ... esac you can do case X { X) . . } > You can also replace the for .. [ in ... ] do ... done > with for .. [ in ... ] { ... }. > This doesn't work for the while loop though (darn!). > This works on 4.1bsd and Venix Bourne shells, but I don't know how > portable it is to other versions. It works on the System III shell, and probably will work on any V7 or post-V7 Bourne shell. 4) > The Bourne shell resembles Algol apparently because S. R. Bourne likes it. > The source code in C is written in the same style, with #define's for > IF, ELSE, and so on. I find it difficult to read. E.g: Yes, Bourne likes Algol 68. He wrote a compiler for Algol 68C, which I believe was for the Cambridge University CAP machine. I think he may have written a PDP-11 UNIX Algol 68 compiler, and an associated debugger called - surprise, surprise - Algol DeBugger, or "adb" for short... he definitely wrote "adb", as one can tell by the same heavy use of the "let's make C look like Algol 68" #defines. PDP-11 "adb" does have a "$a" command to print an "Algol 68 stack trace". By the way, those #defines make it *very* difficult to find unmatched IF...FI pairs and the like, as the error messages are confusing due to wierdities in line numbers and the like. Then again, you have to admire someone who uses the same technique for growing a processes' data space as UNIX uses for growing a processes' stack space... Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy