From: Dan Cross <crossd@gmail.com>
To: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
Cc: TUHS main list <tuhs@tuhs.org>
Subject: [TUHS] Re: A few comments on porting the Bourne shell
Date: Tue, 3 Jan 2023 12:26:49 -0500 [thread overview]
Message-ID: <CAEoi9W7_1eoKVbwyx8dLt1Cd9i+jR+Mg0L99yc+NK4sn7bOk5w@mail.gmail.com> (raw)
In-Reply-To: <CAKH6PiWkt_PzES-RQ4YtmmsUFrgzgabfUaSW5eQpce4uC3-Amw@mail.gmail.com>
On Tue, Jan 3, 2023 at 10:09 AM Douglas McIlroy
<douglas.mcilroy@dartmouth.edu> wrote:
> The forgotten compilers were typically used to supply glue
> to paste major tools together. The nature of that glue---often
> simple data reformatting--inspired tools like sed and awk.
> Each use of a tool became a process that saved many minutes
> of work that would in a scriptless world be guided by hand,
> boringly and unreliably.
This, I think, begs the question I raised earlier: what precisely is
"the shell"? The command interpreter by itself isn't that interesting
without a supporting toolset. And now we get into the crux or what it
means to be "portable": what is the minimum set of such tools that
allow us to write portable shell scripts?
Again I ask, am I allowed to use `nawk`? How about '#!' lines? xargs?
cut? paste?
Perhaps that's the benefit of experience: over time, one develops a
sense of what works across the broadest range of systems that one will
likely encounter. But as Warner pointed out, we can be thankful we're
not using Eunice.
A few years ago, I was having lunch with some folks from the Go team
and one of them remarked, "you shouldn't write a shell script that's
longer than about 10 lines. Once you do, it's time to rewrite it in a
real programming language." I was a bit taken aback, but they had a
point. I'll note that Go standardized on using bash everywhere.
> Yet glue processes typically did only microseconds of
> "real" work. In the name of efficiency, the operations began
> to be incorporated directly into the shell. The first
> inklings of this can be seen in "echo" and various forms
> of variable-substitution making their way into the v7
> shell. The phenomenon proliferated into putting what were
> typically canned sed one-liners (but not sed itself) into
> the shell.
Perhaps I've told this story, but 10 or 12 years ago at Google a
colleague was writing a script to find the location of some resource
or other. I no longer recall what, exactly, but he had written this
massively over-structured thing: shell functions that ran one or two
commands, heavily commented, and he was trying to `return` the exit
status from those commands as the result from the function. It wasn't
working because, well, that's just not how such things work. I sat
down, and rewrote it into about 10 lines; the salient part was that
there was a conditional that determined whether the system it was
running on had a 64-bit or 32-bit userland and ran a handful of
commands depending. I showed him the revised script and he was
uncomfortable; after a while he kind of gave me a look and said,
"yeah, I just don't think people conceptualize of problems that way
anymore." Meaning, it was far more natural for him and others to just
write a Python program instead of a simple script. To him, the script
wasn't simple, but the Python program was.
That has stuck with me for a long, long time. Anyway, we checked the
script in and it worked; it's probably still running, though I suspect
most, if not all, 32-bit systems are gone from Google so perhaps it
was long-ago recycled. I have no idea anymore, but it really gave me
pause: had everything I'd learned about Unix in the prior 20 years
become obsolete? Was I an anachronism amongst my colleagues? Were they
right, and I wrong about how to approach problems?
> Lots of specializations crowded out universality. A side
> effect was an explosion of knowledge required to write
> or understand code. Such is the tragedy of "forgetting
> compilers".
Something I've noticed is that lots of people try to increase
complexity to solve problems, and it rarely occurs to them to
eliminate complexity to solve problems. Sometimes the reasons for this
are good; most of the time they are not.
- Dan C.
next prev parent reply other threads:[~2023-01-03 17:29 UTC|newest]
Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 15:08 Douglas McIlroy
2023-01-03 15:57 ` Alejandro Colomar
2023-01-03 17:19 ` Jon Steinhart
2023-01-05 13:22 ` Tom Ivar Helbekkmo via TUHS
2023-01-05 21:11 ` Rob Pike
2023-01-03 17:26 ` Dan Cross [this message]
2023-01-03 18:07 ` Steve Nickolas
2023-01-03 20:19 ` Steffen Nurpmeso
2023-01-03 23:03 ` ron minnich
2023-01-04 1:37 ` Bakul Shah
2023-01-04 1:58 ` Adam Thornton
2023-01-04 15:19 ` Ralph Corderoy
2023-01-04 18:01 ` Bakul Shah
2023-01-04 20:46 ` Alejandro Colomar
2023-01-05 0:06 ` John Cowan
2023-01-05 0:41 ` Adam Thornton
2023-01-04 5:05 ` Theodore Ts'o
2023-01-03 18:19 ` Niklas Karlsson
2023-01-04 1:29 ` Adam Thornton
2023-01-05 1:51 ` Alejandro Colomar
-- strict thread matches above, loose matches on Subject: below --
2022-12-31 13:26 Douglas McIlroy
2022-12-31 22:19 ` Rob Pike
2022-12-30 18:25 [TUHS] " Paul Ruizendaal
2022-12-30 19:51 ` [TUHS] " Chet Ramey
2022-12-30 20:02 ` Larry McVoy
2022-12-30 20:31 ` Adam Thornton
2022-12-30 20:49 ` Chet Ramey
2022-12-30 20:42 ` Sven Mascheck
2022-12-30 20:48 ` Jon Steinhart
2022-12-30 20:51 ` Sven Mascheck
2022-12-31 11:40 ` Ralph Corderoy
2022-12-31 18:49 ` Jon Steinhart
2022-12-31 19:24 ` Clem Cole
2023-01-03 16:32 ` Chet Ramey
2023-01-01 1:51 ` Ron Natalie
2022-12-30 20:47 ` Chet Ramey
2022-12-31 0:08 ` Luther Johnson
2022-12-31 3:59 ` Larry McVoy
2022-12-31 4:12 ` Steve Nickolas
2022-12-31 4:18 ` Bakul Shah
2022-12-31 4:40 ` Larry McVoy
2022-12-31 4:19 ` Marc Donner
2022-12-31 4:23 ` Dave Horsfall
2022-12-31 4:37 ` Clem Cole
2023-01-02 5:10 ` Mary Ann Horton
2023-01-02 16:25 ` Clem Cole
2023-01-02 16:51 ` Larry McVoy
2023-01-02 17:32 ` Adam Thornton
2023-01-02 17:43 ` Larry McVoy
2023-01-02 17:48 ` Luther Johnson
2023-01-02 18:00 ` G. Branden Robinson
2023-01-02 18:05 ` Luther Johnson
2023-01-02 18:12 ` Larry McVoy
2023-01-02 18:16 ` Clem Cole
2023-01-02 19:50 ` Warner Losh
2023-01-02 20:05 ` Adam Thornton
2023-01-02 19:21 ` G. Branden Robinson
2023-01-02 19:34 ` Rich Salz
2023-01-02 20:12 ` Larry McVoy
2023-01-02 20:24 ` G. Branden Robinson
2023-01-02 20:41 ` Larry McVoy
2023-01-02 21:00 ` Dan Cross
2023-01-02 21:06 ` Clem Cole
2023-01-02 21:19 ` Dan Cross
2023-01-02 22:54 ` segaloco via TUHS
2023-01-02 23:58 ` Jon Steinhart
2023-01-04 9:00 ` Joseph Holsten
2023-01-02 22:43 ` Steve Nickolas
2023-01-02 21:08 ` Joseph Holsten
2023-01-02 21:15 ` Adam Thornton
2023-01-02 17:55 ` Adam Thornton
2023-01-02 18:11 ` Clem Cole
2023-01-02 18:36 ` Dan Cross
2023-01-02 18:48 ` Dan Cross
2023-01-02 18:18 ` Larry McVoy
2023-01-04 3:20 ` John Cowan
2023-01-04 3:31 ` Dan Cross
2023-01-04 4:16 ` Bakul Shah
2023-01-04 16:15 ` Dan Cross
2023-01-04 18:28 ` ron minnich
2023-01-04 19:33 ` Chet Ramey
2023-01-04 15:21 ` Ralph Corderoy
2023-01-04 15:54 ` Ron Natalie
2023-01-02 17:55 ` Clem Cole
2023-01-03 17:08 ` Paul Winalski
2023-01-03 19:19 ` Warner Losh
2023-01-03 19:56 ` Luther Johnson
2023-01-03 20:21 ` Dave Horsfall
2023-01-03 21:47 ` Clem Cole
2023-01-03 21:51 ` Clem Cole
2022-12-31 4:41 ` Greg 'groggy' Lehey
2022-12-30 20:20 ` Sven Mascheck
2022-12-30 20:49 ` Ron Natalie
2022-12-30 20:52 ` Rob Pike
2022-12-30 20:53 ` Jon Steinhart
2023-01-01 10:44 ` arnold
2023-01-01 11:28 ` arnold
2023-01-03 16:34 ` Chet Ramey
2023-01-03 15:06 ` Chet Ramey
2022-12-30 19:57 ` segaloco via TUHS
2022-12-31 12:55 ` Paul Ruizendaal
2023-01-01 2:55 ` Warner Losh
2023-01-01 4:38 ` Jonathan Gray
2023-01-01 5:25 ` Warner Losh
2023-01-01 5:35 ` Dan Cross
2023-01-01 5:52 ` G. Branden Robinson
2023-01-01 6:35 ` Warner Losh
2023-01-01 6:35 ` Rob Pike
2023-01-01 6:27 ` Warner Losh
2023-01-01 14:50 ` Ron Natalie
2023-01-01 7:11 ` Jonathan Gray
2023-01-01 7:21 ` Warner Losh
2023-01-01 10:25 ` Paul Ruizendaal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEoi9W7_1eoKVbwyx8dLt1Cd9i+jR+Mg0L99yc+NK4sn7bOk5w@mail.gmail.com \
--to=crossd@gmail.com \
--cc=douglas.mcilroy@dartmouth.edu \
--cc=tuhs@tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).