diff mbox series

[2/4] t4034: fix use of one-shot variable assignment with shell function

Message ID 20240722065915.80760-3-ericsunshine@charter.net (mailing list archive)
State Superseded
Headers show
Series improve one-shot variable detection with shell function | expand

Commit Message

Eric Sunshine July 22, 2024, 6:59 a.m. UTC
From: Eric Sunshine <sunshine@sunshineco.com>

Unlike "VAR=val cmd" one-shot environment variable assignments which
exist only for the invocation of 'cmd', those assigned by "VAR=val
shell-func" exist within the running shell and continue to do so until
the process exits (or are explicitly unset). In most cases, it is
unlikely that this behavior was intended by the test author, and, even
if those leaked assignments do not impact other tests today, they can
negatively impact tests added later by authors unaware that the variable
assignments are still hanging around. Address this shortcoming by
ensuring that the assignments are short-lived.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t4034-diff-words.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 74586f3813..4dcd7e9925 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -70,7 +70,7 @@  test_language_driver () {
 		word_diff --color-words
 	'
 	test_expect_success "diff driver '$lang' in Islandic" '
-		LANG=is_IS.UTF-8 LANGUAGE=is LC_ALL="$is_IS_locale" \
+		test_env LANG=is_IS.UTF-8 LANGUAGE=is LC_ALL="$is_IS_locale" \
 		word_diff --color-words
 	'
 }