@matheusbsbs / matheus-bagliano / commits / 8cb7980382
Fork 0

t0000: test multiple local assignment

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>

Denton Liu committed Nov 13, 2019 at 16:52 UTC 8cb7980382855f9f696924fec70ed88ea6895030
1 file changed +8 -7
t/t0000-basic.sh
+8 -7
@@ -20,9 +20,9 @@ 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"
23 +try_local_xy () {
24 + local x="local" y="alsolocal" &&
25 + echo "$x $y"
26 }
27
28 # Check whether the shell supports the "local" keyword. "local" is not
@@ -35,11 +35,12 @@ try_local_x () {
35 # relying on "local".
36 test_expect_success 'verify that the running shell supports "local"' '
37 x="notlocal" &&
38 - echo "local" >expected1 &&
39 - try_local_x >actual1 &&
38 + y="alsonotlocal" &&
39 + echo "local alsolocal" >expected1 &&
40 + try_local_xy >actual1 &&
41 test_cmp expected1 actual1 &&
41 - echo "notlocal" >expected2 &&
42 - echo "$x" >actual2 &&
42 + echo "notlocal alsonotlocal" >expected2 &&
43 + echo "$x $y" >actual2 &&
44 test_cmp expected2 actual2
45 '
46