]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t0000: test multiple local assignment
authorDenton Liu <liu.denton@gmail.com>
Thu, 14 Nov 2019 00:52:15 +0000 (16:52 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Nov 2019 00:40:08 +0000 (09:40 +0900)
According to POSIX enhancement request '0000767: Add built-in
"local"'[1],

dash only allows one variable in a local definition; it permits
assignment though it doesn't document that clearly.

however, this isn't true since t0000 still passes with this patch
applied on dash 0.5.10.2. Needless to say, since `local` isn't POSIX
standardized, it is not exactly clear what `local` entails on different
versions of different shells.

We currently already have many instances of multiple local assignments
in our codebase. Ensure that this is actually supported by explicitly
testing that it is sane.

[1]: http://austingroupbugs.net/bug_view_page.php?bug_id=767

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0000-basic.sh

index 4d3f7ba295967e752dcf38f1fb050152ca679eef..a4af2342d1aa314317ad271463dcac75b5f0989e 100755 (executable)
@@ -20,9 +20,9 @@ modification *should* take notice and update the test vectors here.
 
 . ./test-lib.sh
 
-try_local_x () {
-       local x="local" &&
-       echo "$x"
+try_local_xy () {
+       local x="local" y="alsolocal" &&
+       echo "$x $y"
 }
 
 # Check whether the shell supports the "local" keyword. "local" is not
@@ -35,11 +35,12 @@ try_local_x () {
 # relying on "local".
 test_expect_success 'verify that the running shell supports "local"' '
        x="notlocal" &&
-       echo "local" >expected1 &&
-       try_local_x >actual1 &&
+       y="alsonotlocal" &&
+       echo "local alsolocal" >expected1 &&
+       try_local_xy >actual1 &&
        test_cmp expected1 actual1 &&
-       echo "notlocal" >expected2 &&
-       echo "$x" >actual2 &&
+       echo "notlocal alsonotlocal" >expected2 &&
+       echo "$x $y" >actual2 &&
        test_cmp expected2 actual2
 '