From csh(1) weirdness to sh(1) sanity!

Ray Lubinsky rwl at uvacs.UUCP
Sun Apr 13 05:54:25 AEST 1986


> >  I don't see any reason
> > to write scripts in the C-shell, except for the aforementioned
> > exercising of masochistic tendencies.
> 
>   I do. csh(1) has a lot of built-in execution, whereas sh(1) has to
> fork a separate process (test(1)) for every bloody "if" test. Bourne
> shell scripts, on our poor overloaded VAX 750, are slooooooow.

That depends on which Bourne shell you're using.  In the BRL version (dated
23 Dec 1983) ``test'' is a builtin command.  Anyhow, it's possible to write
faster sh(1) scripts on other versions just by turning most ``if''s into
``case'' structures.

The only advantage to csh(1) scripts that I can see is the ease of command
line parsing, but if you have getopt(1), even this isn't that big of an
advantage.  Besides, half the scripts I see are slow because the author forgot
to add the ``-f'' flag to the magic cookie ``#! /bin/csh -f'', so your whole
environment gets loaded into the subshell with no effect but to waste time!

The two big advantages in sh(1) are I/O redirection through control structures
and the fact that sh(1) doesn't eat newlines (like when you're writing an
inline awk(1) script).  For my money, it's Bourne shell for speedy and simple
Unix programming.

-- 

Ray Lubinsky	University of Virginia, Dept. of Computer Science
		UUCP: ...!cbosgd!uvacs!rwl or ...!decvax!mcnc!ncsu!uvacs!rwl



More information about the Comp.bugs.4bsd.ucb-fixes mailing list