Obnoxious postings from Google Groups

Grant Edwards invalid at invalid.invalid
Wed Nov 7 16:13:49 CET 2012

On 2012-11-06, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> On Tue, 06 Nov 2012 11:51:03 -0500, GangGreene wrote:
>> I have just finished a 251 line bash shell script that builds my linux
>> distro from scratch.
> "From scratch"? So if you run it on bare metal with no OS, it works?
> But seriously -- bash is a mature, powerful shell. It works well for
> what it does. It has been designed to make it easy[1] to automate
> system admin tasks.

And even people who have been writing bourne/korn/bash shell sripts
for 30 years (crap, I'm old...) still occasionally (or even regularly)
fall into the "spaces in filenames hole".  It's just too easy to type
$Var instead of "$Var".

And not setting the "nounset" option can result in hours of fun trying
to find that one place where a variable name is mistyped...

> It would be astonishing if an experienced, competent bash 
> programmer couldn't write an installation tool in bash.

Indeed.  But when the good folks at RedHat sat down to write an
installation tool back in '95 or so, they chose Python.

> By comparison, few general purpose programming languages (with the
> obvious exception of perl) are designed for system administration as
> their primary purpose.
> But... how robust is your script? How many bugs does it contain?
> Chances are you will only use it a handful of times, on the same
> system. That's not a lot of testing to be sure that it is free of
> bugs, and robust against unexpected input.
> Hell, even widely used and distributed install scripts written by 
> companies with the resources of Ubuntu and Red Hat have a distressing
> tendency to break. Or worse, to behave in unexpected ways.

That's not really helping your argument, since RedHat's install
scripts have been written in Pyton since forever...

> In my opinion, control structures like "for" and "if" in bash are
> hard to use, hard to read, easy to get wrong, give cryptic error
> messages when you do get them wrong, and are ugly.  Tests are
> obfuscated, and as always, the fact that everything is text in bash
> means it is way harder than it needs to be to use rich, modern data 
> structures.

I think anybody who writes anything of substance in bash would have to
agree.  However when the task involves mainly manipulating files and
running other programs, the clumsy control structures are a small
enough price to pay for the ease with which bash deals with
manipulating files/paths/programs.

OTOH, you can use C shell or PHP and get the worst of both worlds...

Grant Edwards               grant.b.edwards        Yow! I'm wet!  I'm wild!

More information about the Python-list mailing list