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 29819 invoked from network); 5 Jun 2020 01:54:37 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 5 Jun 2020 01:54:37 -0000 Received: (qmail 22654 invoked by alias); 5 Jun 2020 01:54:32 -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: 45974 Received: (qmail 26083 invoked by uid 1010); 5 Jun 2020 01:54:32 -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/25828. spamassassin: 3.4.4. Clear:RC:0(192.241.140.119):SA:0(-2.0/5.0):. Processed in 3.874023 secs); 05 Jun 2020 01:54:32 -0000 X-Envelope-From: sandals@crustytoothpaste.net X-Qmail-Scanner-Mime-Attachments: | 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) From: "brian m. carlson" To: zsh-workers@zsh.org Subject: [PATCH v2 0/1] Run pipeline command in subshell in sh mode Date: Fri, 5 Jun 2020 01:53:37 +0000 Message-Id: <20200605015338.1347787-1-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POSIX sh implementations run each command in a pipeline in a subshell, although zsh (and AT&T ksh) do not: instead, they run the final command in the main shell. This leads to very different behavior when the final command is a shell function which modifies variables. zsh is starting to be used in some cases as /bin/sh, such as on macOS Catalina. Consequently, it makes sense to emulate the POSIX behavior as much as possible when emulating sh, since that's the least surprising behavior. This patch does exactly that. With this patch, using "zsh --emulate sh" passes the Git testsuite. I expect that it will also be fully functional as /bin/sh on Debian, although I have not tested. This patch was sent before, but didn't get picked up. In hopes of aiding reviewers, I've resent it with a significantly expanded commit message so that it is easier to reason about. I'm not subscribed to the list, so please CC me if you have questions or comments. brian m. carlson (1): exec: run final pipeline command in a subshell in sh mode Src/exec.c | 10 ++++++---- Test/B07emulate.ztst | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-)