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

[PATCH 1/1] t9001: avoid including non-trailing NUL bytes in variables

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Nov 27, 2019, 19:01 UTC
Message-ID
<20191127190142.64271-2-sandals@crustytoothpaste.net>
In-Reply-To
<20191127190142.64271-1-sandals@crustytoothpaste.net>

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>" \
Previous: brian m. carlson
Message 2 of 2 in “Fix broken test with zsh as /bin/sh”
  1. 0/1 Fix broken test with zsh as /bin/shbrian m. carlson, Nov 27, 2019
  2. 1/1 t9001: avoid including non-trailing NUL bytes in variablesbrian m. carlson, Nov 27, 2019

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.