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=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3946 invoked from network); 11 Jun 2020 00:25:01 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 11 Jun 2020 00:25:01 -0000 Received: (qmail 1271 invoked by alias); 11 Jun 2020 00:24:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 46042 Received: (qmail 29163 invoked by uid 1010); 11 Jun 2020 00:24:46 -0000 X-Qmail-Scanner-Diagnostics: from injection.crustytoothpaste.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25835. spamassassin: 3.4.4. Clear:RC:0(192.241.140.119):SA:0(-2.0/5.0):. Processed in 1.396284 secs); 11 Jun 2020 00:24:46 -0000 X-Envelope-From: sandals@crustytoothpaste.net X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at crustytoothpaste.net designates 192.241.140.119 as permitted sender) Date: Thu, 11 Jun 2020 00:24:03 +0000 From: "brian m. carlson" To: Bart Schaefer Cc: "zsh-workers@zsh.org" Subject: Re: [PATCH v2] exec: run final pipeline command in a subshell in sh mode Message-ID: <20200611002403.GY6569@camp.crustytoothpaste.net> References: <20200605015338.1347787-1-sandals@crustytoothpaste.net> <20200605015338.1347787-2-sandals@crustytoothpaste.net> <20200605204144.GD6569@camp.crustytoothpaste.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Qesg98+uAFykT7J8" Content-Disposition: inline In-Reply-To: X-Machine: Running on camp using GNU/Linux on x86_64 (Linux kernel 5.6.0-2-amd64) --Qesg98+uAFykT7J8 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-06-07 at 16:55:54, Bart Schaefer wrote: > On Fri, Jun 5, 2020 at 1:42 PM brian m. carlson > wrote: > > > > I will tell you that as a practical matter, nobody writing code for sh > > expects the last command not to be run in a subshell and consequently > > lots of code is practically broken in this case with zsh as /bin/sh. >=20 > I believe you, but would be curious to see an example. I'll demonstrate an example from the Git testsuite (t1300), which is necessarily incomplete, and whose behavior baffles me a bit. echo "[broken" | test_must_fail git config --list --file - >output 2>&1 && test_i18ngrep "bad config line 1 in standard input" output test_must_fail checks for a nonzero, non-SIGSEGV exit code, and test_i18ngrep is a glorified grep operation which always succeeds when LC_ALL=3DC doesn't work. There is also a lot of FD redirection going on under the hood. This operation fails, interestingly enough, because grep complains that the output is also the input; that is, the redirection of stdout on the previous line applies to the grep as well. I'm unable to reproduce this with a simpler example, but putting it in a subshell does work. AT&T ksh does not have this behavior, and so this may be a legitimate bug in zsh which my patch happens to fix. The other case (t0410) in the Git testsuite is more straightforward; we have this function: pack_as_from_promisor () { HASH=3D$(git -C repo pack-objects .git/objects/pack/pack) && >repo/.git/objects/pack/pack-$HASH.promisor && echo $HASH } and that function is then called on the right end of a pipe. The caller was not expecting that HASH would be overwritten, and since until recently the Git testsuite did not allow "local" and this test has not been updated, the test gets the wrong value. --=20 brian m. carlson: Houston, Texas, US OpenPGP: https://keybase.io/bk2204 --Qesg98+uAFykT7J8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.2.20 (GNU/Linux) iHUEABYKAB0WIQQILOaKnbxl+4PRw5F8DEliiIeigQUCXuF5owAKCRB8DEliiIei gTxdAP9X7Gpr1cNcDOHph6fvJSvsBP8lwfAf5hKF5LSfkXX8YQD/X/yECmDvgDed EIcWBD60Ydjpdu9fq/KjU5ICe/0b0As= =m98d -----END PGP SIGNATURE----- --Qesg98+uAFykT7J8--