git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/1] Run pipeline command in subshell in sh mode

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 6, 2020, 00:22 UTC
Message-ID
<20200606002241.1578150-2-sandals@crustytoothpaste.net>
In-Reply-To
<20200606002241.1578150-1-sandals@crustytoothpaste.net>

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(-)
Previous: brian m. carlsonNext: brian m. carlson
Message 5 of 9 in “git-fast-import out of memory”
  1. Billes TiborJun 5, 2020
  2. brian m. carlsonJun 5, 2020
  3. fast-import: fix incomplete conversion with multiple mark filesbrian m. carlson, Jun 6, 2020
  4. exec: run final pipeline command in a subshell in sh modebrian m. carlson, Jun 6, 2020
  5. 0/1 Run pipeline command in subshell in sh modebrian m. carlson, Jun 6, 2020
  6. brian m. carlsonJun 6, 2020
  7. Tibor BillesJun 8, 2020
  8. Junio C HamanoJun 8, 2020
  9. brian m. carlsonJun 8, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.