From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30958 invoked from network); 3 Jan 2023 17:29:07 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 3 Jan 2023 17:29:07 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id AFD0542507; Wed, 4 Jan 2023 03:28:32 +1000 (AEST) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by minnie.tuhs.org (Postfix) with ESMTPS id CE9BA42506 for ; Wed, 4 Jan 2023 03:28:27 +1000 (AEST) Received: by mail-lj1-f169.google.com with SMTP id n1so32643830ljg.3 for ; Tue, 03 Jan 2023 09:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2fTukUk9x42lebKATOaGhBJWql7JNR64RMehhzN0aA4=; b=MP2Ty+OIpVyBD4NWUVOm6iTkAPmSAhZ9hNDxtjh/ylr/bjQlC0KTvJXun94kjWsvs/ WLezoPQrr4EhajBnEnB33rr289kUaa5LnDqUYbQ+wHTkjqyqMXcKqJuiikjgOKi7Dh43 7RKROe2v+sW28XlT/0Gi1O0Y7VxGBzN2p4BfCQxFULAIEW2f9hkyKZbdMM1YiGEKb9yD Io/srocrbbNjNXK6UG7qpo3AVSoH1jXIt4mvwupN6GTEJOuJdAOgSZgQsyXtr9mM6QhT zdAmtDkbXKh6QDzFYlatic+XhdQuGAJhndCj83c+geXjaf4JpxaCE/5oxroohyWoEGv5 +Ufg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2fTukUk9x42lebKATOaGhBJWql7JNR64RMehhzN0aA4=; b=xtflmBwcJ3HqbOknnds8C6ucp7v7U4gqZkEkiBYD0SedKJZZ37PnyIFIZXHvccY4e8 Pl8Fa/RK/E/c2RHn2aAR1e+Co7+MR32yaqOA9VgDtENJrNFKg0UAX0paUSfJEYM01aEa GhY8T0OJ3b3heGrOah2QtELVfsjrVCGqUtL+6OkuarTia94cuGzgqM2cTeGOCgyZchb8 JyIoZ1k15u7e4XgaV2FqHj9h733mC88ajf8wPoYdHcklO7zBtycro9Kx1RCCMubIQ+im Geau2vqoz2RBFMxTWJJtEhpvO6NxEIr78BUSTxKV43VCOuTcZPCZh0858Wkfu28d5BjJ oN3g== X-Gm-Message-State: AFqh2koQXoPG8tcWnubUKTlO4f7gVvQD8B56MzvQm4L9atZmgyvlrE/r uHzijxepqowR9qjPo+gQpQXsX7Vkiy1arAA91Q6TgLAWwWw= X-Google-Smtp-Source: AMrXdXvwt0qbNweR/sxaQMiI3pQHbXQB2LYmxTO0H15LaqJDYoe4hn87M7p2BjhRoLeCNQT0aMPRnVJHfTWLKM4xhk8= X-Received: by 2002:a2e:bd01:0:b0:27f:c69a:11b7 with SMTP id n1-20020a2ebd01000000b0027fc69a11b7mr2157997ljq.111.1672766846138; Tue, 03 Jan 2023 09:27:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Dan Cross Date: Tue, 3 Jan 2023 12:26:49 -0500 Message-ID: To: Douglas McIlroy Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: ITJW3XTZNDFJ47VG3SUVFORQMQFWORWU X-Message-ID-Hash: ITJW3XTZNDFJ47VG3SUVFORQMQFWORWU X-MailFrom: crossd@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-tuhs.tuhs.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: TUHS main list X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: A few comments on porting the Bourne shell List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Jan 3, 2023 at 10:09 AM Douglas McIlroy 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.