[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: general replies, last in thread?

From: Zack Weinberg <zack_at_codesourcery.com>
Date: 2002-02-06 23:59:34 CET

On Wed, Feb 06, 2002 at 02:05:04AM -0800, Tom Lord wrote:
>
> * Isn't Zack really neurotic about shell scripts?
>
> Yup, he sure is. The shell is far from perfect, but Zack is
> over-reacting. Consider all the booting and sysadmin infrastructure
> on every unix-ish box (built from shell scripts). Consider how GCC,
> to which Zack contributes heavily, is configured and built.
> Consider the once extremely popular MH mail handling system.
> Consider the history of CVS. I'm sure the list could go on...

Yes, I am aware that my attitude toward shell scripts can appear
irrational. It is, however, a considered position; after years of
experience, I have come to the conclusion that they are never the
right answer to any problem which is more complex than something you
might type interactively. Yes, this does include the boot scripts,
the MH system (which I used to use), GCC's configure script, dpkg's
helper programs, everything. All of them are bugs waiting to happen.

First, there simply is no such thing as a portable shell script.
Configure scripts are not a counterexample; their apparent portability
is a seductive and dangerous illusion. Consider, for example, the
periodic reports of the libstdc++3 configure script taking several
hours to run[1]. Consider the sheer volume of code in each and every
one of these scripts devoted to working around obscure bugs in
different versions of the shell, or its helper utilities.

Second, even if you are so lucky as to be able to specify one
particular Bourne shell implementation to be used with your script,
the quoting rules are guaranteed to cause catastrophic failure
eventually.[2]

Third, the language spec is old enough that it doesn't incorporate
modern safety features like, oh, local variables (yes, I know about
bash's "local", but that's not portable - see point 1) which means
that any large shell script will inevitably become an unmaintainable
morass within a few months of its creation.

Now there are valid reasons to use shell scripts, even in the face of
all this. The most common is backward compatibility with an existing
system, such as Make or Autoconf. However, when one is creating a
brand new system from scratch, e.g. arch, there simply is no excuse.

zw

[1] http://gcc.gnu.org/ml/gcc/2001-03/msg00804.html and subsequent thread
[2] http://gcc.gnu.org/ml/gcc/1999-04n/msg00422.html and subsequent
    thread -- note that it was eventually discovered that even this
    was not good enough, and it was totally impossible to get the
    quoting in FLAGS_TO_PASS to work in all circumstances. I can't
    find that thread at the moment.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:05 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.