Skip to content

Commit 01d3a52

Browse files
mhaggergitster
authored andcommitted
t0000: check whether the shell supports the "local" keyword
Add a test balloon to see if we get complaints from anybody who is using a shell that doesn't support the "local" keyword. If so, this test can be reverted. If not, we might want to consider using "local" in shell code throughout the git code base. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb5918a commit 01d3a52

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

t/t0000-basic.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ modification *should* take notice and update the test vectors here.
2020

2121
. ./test-lib.sh
2222

23+
try_local_x () {
24+
local x="local" &&
25+
echo "$x"
26+
}
27+
28+
# This test is an experiment to check whether any Git users are using
29+
# Shells that don't support the "local" keyword. "local" is not
30+
# POSIX-standard, but it is very widely supported by POSIX-compliant
31+
# shells, and if it doesn't cause problems for people, we would like
32+
# to be able to use it in Git code.
33+
#
34+
# For now, this is the only test that requires "local". If your shell
35+
# fails this test, you can ignore the failure, but please report the
36+
# problem to the Git mailing list <[email protected]>, as it might
37+
# convince us to continue avoiding the use of "local".
38+
test_expect_success 'verify that the running shell supports "local"' '
39+
x="notlocal" &&
40+
echo "local" >expected1 &&
41+
try_local_x >actual1 &&
42+
test_cmp expected1 actual1 &&
43+
echo "notlocal" >expected2 &&
44+
echo "$x" >actual2 &&
45+
test_cmp expected2 actual2
46+
'
47+
2348
################################################################
2449
# git init has been done in an empty repository.
2550
# make sure it is empty.

0 commit comments

Comments
 (0)