Shell programming style -- a plea for better shell scripts
Guy Harris
guy at rlgvax.UUCP
Fri Feb 17 16:13:22 AEST 1984
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
More information about the Comp.unix
mailing list