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 7204 invoked from network); 4 Jan 2023 16:17:21 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 4 Jan 2023 16:17:21 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 024A94255D; Thu, 5 Jan 2023 02:17:00 +1000 (AEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by minnie.tuhs.org (Postfix) with ESMTPS id 0AA2942552 for ; Thu, 5 Jan 2023 02:16:56 +1000 (AEST) Received: by mail-lj1-f174.google.com with SMTP id q2so35930212ljp.6 for ; Wed, 04 Jan 2023 08:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A9kofxKI7fwKXuyDtHETVkye7JzT2gszvMwat2RzJdY=; b=NfX9Pvnlrv4Wb37JQL5niLogAr6h79bcaRISK6YI9PFXcNrpLLQZi1NjtWm05PcIgl YZ/7W7NRk6IL4QAEieVbjNzQkQ6u5/6RcBGENhYHwds2frN7/aYJcvNZcWPY+OuwWa+2 6HiK/auziH3da+S1oz0kW3u1Iao7lYpXVtJM5eyRvgZU3mjCI4EHRIav5T5okNDs3oEk XaUSNusmkPzF4oSrAMO6JV+yK64tslRLCqioCnb84ZlHDLDrqCcz+GYsyLratgu5HfdB QVjbOWeUZ+nTBahepg18iyHjALJjd8bmjaY4Ru/0uuHHQaBqIKgaRJ4nb1hYO/2/yrmk SyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=A9kofxKI7fwKXuyDtHETVkye7JzT2gszvMwat2RzJdY=; b=MKkklYRHNZEK+Fuuq7GcW1LtEXzbr0cAslJTy538QF+H4j72Usjt71MVVbXNz6uXUN 4Scw7zDCUbkvlZI35WWbU8xHMO/o4HdH4wD8+fCWfMUCoZSUs5VunBucsxUn32bjM2J0 z1abIzcDAq+NETx/m9LYsJ2BKixTwnssmdxI7ja2Sry8Ua/Jfd2Tp4Pt0cjjtCfFqpu5 aIMPrACx74ihXQBfyq+4rcYd0qABWKmc9JY2qgyfCPe2iEpraKF8dK9H6q6MJgJfocdB DlAHAxQydqdnRUuPrv67JDnBY8E6mG000kNWXrws2hGXO9XvR8rzVJo4cvq3qNUQh7KA EaUA== X-Gm-Message-State: AFqh2koi4V3tQVLlHFB6vDbIHvSy9BPRYp5alqKvFT5ETQIdUX77S/nm UKIQCBppr8WQ0lVHcV93tSTir3RSVRemwcu/VdYXEQGtOU8= X-Google-Smtp-Source: AMrXdXt1H9pi7aIRlKULaxAOu4kAJ+iM5tjxOFrWGLslssgrHA7Vk6QdpOxSIEQc5QDt0FHlYUqW5j4hnDvx8ngO47o= X-Received: by 2002:a2e:8615:0:b0:27f:d9a7:6395 with SMTP id a21-20020a2e8615000000b0027fd9a76395mr1727495lji.215.1672848954315; Wed, 04 Jan 2023 08:15:54 -0800 (PST) MIME-Version: 1.0 References: <52FB6638-AEFF-4A4F-8C2E-32089D577BA0@planet.nl> <464819f0-d2f6-2a60-6481-a194f4428b4d@case.edu> <20221230200246.GW5825@mcvoy.com> <88f83b4c-b3f9-ed87-b2fa-560fb369742a@makerlisp.com> <20221231035931.GG5825@mcvoy.com> <528f0c53-ccc2-88a1-5a7b-120362c648dd@mhorton.net> <20230102165120.GK25547@mcvoy.com> <20230102174304.GM25547@mcvoy.com> In-Reply-To: From: Dan Cross Date: Wed, 4 Jan 2023 11:15:17 -0500 Message-ID: To: Bakul Shah Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HLE5MJWDHF2WWU37AONFGZUK5QTD24YA X-Message-ID-Hash: HLE5MJWDHF2WWU37AONFGZUK5QTD24YA 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: The Eunuchs Hysterical Society 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 11:16 PM Bakul Shah wrote: > On Jan 3, 2023, at 7:31 PM, Dan Cross wrote: > > On Tue, Jan 3, 2023 at 10:22 PM John Cowan wrote: > >> Making shell scripts portable means not using pipelines, because given= "foo | bar", kshNN and zsh execute foo in a subshell and bar in the top-le= vel shell, whereas in other shells, both foo and bar execute in subshells. = (For this reason, Posix allows either behavior.) Not having pipelines is = a pretty drastic limitation. > > > > This came up at work just the other day: > > > > echo ' hi ' | sed 's/^ *//;s/ *$//' | read bummer > > echo $bummer > > > > The behavior varies between ksh, zsh, bash, sh. Yay. > > On this example sh, zsh, bash behave the same way on > freebsd. Rather than ban |, I think the lesson is to > *avoid* builtin commands in a pipeline that can affect > shell's environment. I only write /bin/sh scripts in > any case. Interesting. In my testing, `bash` was the odd man out: : doctor; zsh : doctor; echo ' hi ' | sed 's/^ *//;s/ *$//' | read bummer echo $bummer hi : doctor; : doctor; bash : doctor; echo ' hi ' | sed 's/^ *//;s/ *$//' | read bummer echo $bummer : doctor; exit : doctor; ksh : doctor; echo ' hi ' | sed 's/^ *//;s/ *$//' | read bummer : doctor; echo $bummer hi : doctor; : doctor; sh : doctor; echo ' hi ' | sed 's/^ *//;s/ *$//' | read bummer : doctor; echo $bummer hi : doctor; : doctor; That's on illumos. On OpenBSD, neither bash, ksh, or sh produce output, while zsh does. I suspect ksh is pdksh and sh is a link to ksh there, though. ksh93 gives "hi". On FreeBSD, neither bash nor sh produce "hi", but zsh and ksh93 do. Same on DragonFly, macOS and Arch Linux. On 7th edition, I only tried sh; empty output. 4.3BSD gives empty output for /bin/sh. For kicks, neither tcsh nor csh understand `read`; I don't think that *csh has a read-like builtin. This is, of course, a silly example. Most script authors would do something like: bummer=3D`echo ' hi ' | sed 's/^ *//;s/ *$//'` Or, perhaps even: bummer=3D$(echo ' hi ' | sed 's/^ *//;s/ *$//') Life's too short and at this point I prefer the latter, but more often than not my fingers are wired for the former. > It is really unfortunate that infix | is so beguiling! > Except for that a Lisp or Scheme based shell would've > been fine and dandy! :-)/2 Whatever happened to `es` ? I guess it died on the vine. It seemed like a nifty idea. I made a concerted effort to use `rc` as my shell on Unix for a little while. Without all the supporting plan9 machinery, though, I gave up. Minimalism is great in an environment that can augment it with useful functionality; outside of that environment, it can be kind of a pain for work-a-day use. - Dan C.