zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH v2 0/1] Run pipeline command in subshell in sh mode
@ 2020-06-05  1:53 brian m. carlson
  2020-06-05  1:53 ` [PATCH v2] exec: run final pipeline command in a " brian m. carlson
  0 siblings, 1 reply; 14+ messages in thread
From: brian m. carlson @ 2020-06-05  1:53 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-07-03 20:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05  1:53 [PATCH v2 0/1] Run pipeline command in subshell in sh mode brian m. carlson
2020-06-05  1:53 ` [PATCH v2] exec: run final pipeline command in a " brian m. carlson
2020-06-05 10:21   ` Mikael Magnusson
2020-06-05 20:41     ` brian m. carlson
2020-06-06  4:33       ` [PATCH v2] exec: run final pipeline command in a subshell in sh modeZZ Daniel Shahaf
2020-06-06 16:28         ` brian m. carlson
2020-06-07 11:29           ` Daniel Shahaf
2020-06-07 16:55       ` [PATCH v2] exec: run final pipeline command in a subshell in sh mode Bart Schaefer
2020-06-07 17:24         ` Peter Stephenson
2020-06-09  7:57           ` Daniel Shahaf
2020-06-09 10:54             ` Mikael Magnusson
2020-06-17 18:26               ` Daniel Shahaf
2020-07-03 20:16                 ` brian m. carlson
2020-06-11  0:24         ` brian m. carlson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).