git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] Fix broken test with zsh as /bin/sh
@ 2019-11-27 19:01 brian m. carlson
  2019-11-27 19:01 ` [PATCH 1/1] t9001: avoid including non-trailing NUL bytes in variables brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: brian m. carlson @ 2019-11-27 19:01 UTC (permalink / raw)
  To: git

macOS Catalina provides zsh as one of the three options for /bin/sh (the
other two being bash and dash).  Therefore, it's possible that people
will use zsh as /bin/sh and expect it to work when running Git and the
testsuite.

There are two things required for this to happen.  One is a patch to zsh
to make it run all items in a pipeline in a subshell in sh mode, just as
POSIX requires.  I've sent a patch[0] upstream to make that happen;
without that patch, multiple tests fail.

The other is this patch, which addresses a difference in behavior
between bash and dash, which strip out NUL bytes from the output of a
command substitution, and zsh, which does not.  Both behaviors are
permitted by POSIX, so this patch makes the test work in either case.

[0] https://www.zsh.org/mla/workers/2019/msg00960.html

brian m. carlson (1):
  t9001: avoid including non-trailing NUL bytes in variables

 t/t9001-send-email.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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

* [PATCH 1/1] t9001: avoid including non-trailing NUL bytes in variables
  2019-11-27 19:01 [PATCH 0/1] Fix broken test with zsh as /bin/sh brian m. carlson
@ 2019-11-27 19:01 ` brian m. carlson
  0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2019-11-27 19:01 UTC (permalink / raw)
  To: git

In this test, we have a command substitution whose output starts with a
NUL byte.  bash and dash strip out any NUL bytes from the output; zsh
does not.  As a consequence, zsh fails this test, since the command line
argument we use the variable in is truncated by the NUL byte.

POSIX says of a command substitution that if "the output contains any
null bytes, the behavior is unspecified," so all of the shells are in
compliance with POSIX.  To make our code more portable, let's avoid
prefacing our variables with NUL bytes and instead leave only the
trailing one behind.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t9001-send-email.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 997f90b42b..51be0b8cd6 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -2066,7 +2066,7 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
 	TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
 	TO2=$(echo "QZto2" | qz_to_tab_space) &&
 	CC1=$(echo "cc1" | append_cr) &&
-	BCC1=$(echo "Q bcc1@example.com Q" | q_to_nul) &&
+	BCC1=$(echo " bcc1@example.com Q" | q_to_nul) &&
 	git send-email \
 	--dry-run \
 	--from="	Example <from@example.com>" \

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

end of thread, other threads:[~2019-11-27 19:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 19:01 [PATCH 0/1] Fix broken test with zsh as /bin/sh brian m. carlson
2019-11-27 19:01 ` [PATCH 1/1] t9001: avoid including non-trailing NUL bytes in variables brian m. carlson

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

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).