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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Oct 26, 2017 at 10:18 UTC
01d3a526ad9a37938f3597b2c160d699904cb8b8
1 file changed
+25
t/t0000-basic.sh
+25
@@ -20,6 +20,31 @@ modification *should* take notice and update the test vectors here.
20
21
. ./test-lib.sh
22
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 <git@vger.kernel.org>, 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
+
48
################################################################
49
# git init has been done in an empty repository.
50
# make sure it is empty.