git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 0/2] Test fixes when running with zsh in sh mode
Date: Fri, 26 Apr 2024 22:11:52 +0000	[thread overview]
Message-ID: <20240426221154.2194139-1-sandals@crustytoothpaste.net> (raw)

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


             reply	other threads:[~2024-04-26 22:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 22:11 brian m. carlson [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240426221154.2194139-1-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).