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

[PATCH 0/2] Test fixes when running with zsh in sh mode

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 26, 2024, 22:11 UTC
Message-ID
<20240426221154.2194139-1-sandals@crustytoothpaste.net>

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(-)
Next: brian m. carlson
Message 1 of 4 in “Test fixes when running with zsh in sh mode”
  1. 0/2 Test fixes when running with zsh in sh modebrian m. carlson, Apr 26, 2024
  2. 2/2 vimdiff: make script and tests work with zshbrian m. carlson, Apr 26, 2024
  3. 1/2 t4046: avoid continue in &&-chain for zshbrian m. carlson, Apr 26, 2024
  4. Junio C HamanoApr 27, 2024

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.