git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Test fixes when running with zsh in sh mode
@ 2024-04-26 22:11 brian m. carlson
  2024-04-26 22:11 ` [PATCH 1/2] t4046: avoid continue in &&-chain for zsh brian m. carlson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: brian m. carlson @ 2024-04-26 22:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

zsh is a common shell on a variety of systems, primarily for interactive
use.  However, it can be used as a POSIX sh on Debian, macOS, and on other
systems where /bin/sh is not POSIX compliant or doesn't provide the
local keyword as we require from our shell.

This series fixes two test failures with zsh when run in sh mode; that
is, the mode that occurs when the shell is invoked as "sh".  sh mode
provides the most POSIX-compliant behavior and avoids a lot of
incompatibilities that the default zsh mode provides.

Additionally, as of zsh 5.9, thanks to a patch I sent, zsh also runs all
parts of a pipeline in a subshell when in sh mode, which fixes a
substantial portion of our testsuite.  POSIX specifies this behavior,
but allows shells to run any or all portions in the main shell instead
as an extension, and the default zsh and AT&T ksh behavior[0] is to run the
final element in a pipeline in the main shell, which breaks lots of our
testsuite.  This, and the fact that every default /bin/sh implementation
_does_ run all the elements in a subshell, is the reason I sent that
patch.

One of the two test failures is due to a zsh bug already fixed upstream
but not yet released, and the other is due to zsh complying with the
standard more strictly than competing shells.  With this series, we can
do this[1]:

----
#!/bin/sh

mkdir -p "$TMPDIR/shell"
ln -s /usr/bin/zsh "$TMPDIR/shell/sh"
make -j8 SHELL_PATH="$TMPDIR/shell/sh" && (cd t && make prove SHELL_PATH=$TMPDIR/shell/sh GIT_PROVE_OPTS=-j8)
----

and the testsuite passes.

Note that this series doesn't make any attempt to make zsh pass the
testsuite in any mode other than sh mode and I have not even tested such
a configuration (which I am sure is horribly broken and would probably
require invasive patches to fix).

These issues are long-standing and probably don't need to be merged down
to maint unless you really feel like it.

[0] Note that AT&T ksh does not support local, so its behavior is
    already very broken with regard to our scripts and testsuite.  Other
    ksh implementations, such as mksh and lksh (MirBSD ksh), pdksh, and
    OpenBSD's ksh/sh _do_ support local and _do_ run all elements of a
    pipeline in a subshell, so they are fully functional with our
    testsuite already.

[1] Please note that I am using user-private temporary directories and
    you should otherwise choose a different directory than `$TMPDIR`.

brian m. carlson (2):
  t4046: avoid continue in &&-chain for zsh
  vimdiff: make script and tests work with zsh

 mergetools/vimdiff       |  3 +--
 t/t4046-diff-unmerged.sh | 16 +++++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)


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

end of thread, other threads:[~2024-04-27 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26 22:11 [PATCH 0/2] Test fixes when running with zsh in sh mode brian m. carlson
2024-04-26 22:11 ` [PATCH 1/2] t4046: avoid continue in &&-chain for zsh brian m. carlson
2024-04-26 22:11 ` [PATCH 2/2] vimdiff: make script and tests work with zsh brian m. carlson
2024-04-27 17:23 ` [PATCH 0/2] Test fixes when running with zsh in sh mode Junio C Hamano

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