{"thread":{"id":"52362","subject":"[PATCH 0/1] Fix broken test with zsh as /bin/sh","startedAt":"2019-11-27T19:01:56Z","lastAt":"2019-11-27T19:01:56Z","messageCount":2,"participants":["brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"387203","messageId":"20191127190142.64271-1-sandals@crustytoothpaste.net","threadId":"52362","inReplyTo":null,"subject":"[PATCH 0/1] Fix broken test with zsh as /bin/sh","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-11-27T19:01:41Z","receivedAt":"2019-11-27T19:01:56Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"macOS Catalina provides zsh as one of the three options for /bin/sh (the\nother two being bash and dash).  Therefore, it's possible that people\nwill use zsh as /bin/sh and expect it to work when running Git and the\ntestsuite.\n\nThere are two things required for this to happen.  One is a patch to zsh\nto make it run all items in a pipeline in a subshell in sh mode, just as\nPOSIX requires.  I've sent a patch[0] upstream to make that happen;\nwithout that patch, multiple tests fail.\n\nThe other is this patch, which addresses a difference in behavior\nbetween bash and dash, which strip out NUL bytes from the output of a\ncommand substitution, and zsh, which does not.  Both behaviors are\npermitted by POSIX, so this patch makes the test work in either case.\n\n[0] https://www.zsh.org/mla/workers/2019/msg00960.html\n\nbrian m. carlson (1):\n  t9001: avoid including non-trailing NUL bytes in variables\n\n t/t9001-send-email.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\n"},{"id":"387204","messageId":"20191127190142.64271-2-sandals@crustytoothpaste.net","threadId":"52362","inReplyTo":"20191127190142.64271-1-sandals@crustytoothpaste.net","subject":"[PATCH 1/1] t9001: avoid including non-trailing NUL bytes in variables","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-11-27T19:01:42Z","receivedAt":"2019-11-27T19:01:56Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"In this test, we have a command substitution whose output starts with a\nNUL byte.  bash and dash strip out any NUL bytes from the output; zsh\ndoes not.  As a consequence, zsh fails this test, since the command line\nargument we use the variable in is truncated by the NUL byte.\n\nPOSIX says of a command substitution that if \"the output contains any\nnull bytes, the behavior is unspecified,\" so all of the shells are in\ncompliance with POSIX.  To make our code more portable, let's avoid\nprefacing our variables with NUL bytes and instead leave only the\ntrailing one behind.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9001-send-email.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 997f90b42b..51be0b8cd6 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -2066,7 +2066,7 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '\n \tTO1=$(echo \"QTo 1 <to1@example.com>\" | q_to_tab) &&\n \tTO2=$(echo \"QZto2\" | qz_to_tab_space) &&\n \tCC1=$(echo \"cc1\" | append_cr) &&\n-\tBCC1=$(echo \"Q bcc1@example.com Q\" | q_to_nul) &&\n+\tBCC1=$(echo \" bcc1@example.com Q\" | q_to_nul) &&\n \tgit send-email \\\n \t--dry-run \\\n \t--from=\"\tExample <from@example.com>\" \\\n"}]}