Skip to content

Run pipeline command in subshell in sh mode

brian m. carlson git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest0 of 1 patch 1 replyIn review

Patches in v2 No applies recorded yet

The patch the cover letter announces is not in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

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

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(-)