🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1024

Re: bourne shell query

#1024
From: Roger Rohrbach
Date: Mon, 10 Sep 1990 19:19
53 lines
2813 bytes
goudreau@dg-rtp.dg.com (Bob Goudreau) writes:

>So let me get this straight:
>
>Making shell scripts needlessly obscure (i.e., no increase in either
>functionality or performance, and a downright *decrease* in
>readability) is supposed to be a *good thing* ??!!
>
>Call it "art" if you will, and feel free to start a rec.arts.shell
>newsgroup.  I prefer to call it "bad software engineering".


I agree that shell programs should be readable, but "needlessly obscure"
is subjective.  On the one hand, the shell syntax (outside of the control
structures) is pretty obscure to begin with, because it relies so much
on context-sensitive treatment of single characters.  On the other hand,
the shell language per se is small enough that I don't consider certain
combinations to be obscure, even though they are not used by most casual
shell programmers; i.e., I believe it is our responsibility to learn the
language.  I alway try to write in a way that minimizes obscurity intro-
duced by the former.  Thus, I don't like to write complicated pipelines
that go in and out of single- and double-quotes to pass shell variables
and backquote expressions to sed scripts!  But I do use goal-directed
programming (program components that "succeed" or "fail") extensively,
even though people not familiar with the style (including my boss!) call
it "obscure"- I tell them to look at Prolog or Icon, or even the C `?:'
operator (my boss only knows C :-)  If a language provides a succinct
notation, I think it's good to consider the use of same "succinct", not
"obscure".  As an example, I prefer

    grep '^roger:' /etc/passwd > /dev/null ||
    {
        echo "roger is not a user" >&2
        exit 1
    }

to

    if grep '^roger:' /etc/passwd > /dev/null
    then
        :
    else
        echo "roger is not a user" >&2
        exit 1
    fi

and would consider it *more* readable, especially if it were nested within
another "if-then-else" statement or loop.

Roger Rohrbach                                  sun!wrs!roger    roger@wrs.com
- Eddie sez: ----------------------------------------------- (c) 1986, 1990 -.
|   {o >o                                                                     |
|    \ -) "I was an infinitely hot and dense dot."                            |
Technical Details
Message-ID: <1216@wrs.wrs.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!pacbell.com!pacbell!rtech!wrs!kymijoki!roger
References: <26DC6447.15922@maccs.dcss.mcmaster.ca> <8446@orca.wv.tek.com> <SCOTT.90Sep6120011@tab00.larc.nasa.gov> <1990Sep7.194320.27259@dg-rtp.dg.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!pacbell.com!pacbell!rtech!wrs!kymijoki!roger
From: roger@kymijoki.wrs.com (Roger Rohrbach)
Newsgroups: comp.unix.shell
Subject: Re: bourne shell query
Message-ID: <1216@wrs.wrs.com>
Date: 10 Sep 90 19:19:51 GMT
References: <26DC6447.15922@maccs.dcss.mcmaster.ca> <8446@orca.wv.tek.com> <SCOTT.90Sep6120011@tab00.larc.nasa.gov> <1990Sep7.194320.27259@dg-rtp.dg.com>
Sender: news@wrs.wrs.com
Lines: 53