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>
This commit is contained in:
Denton Liu 2019-11-13 16:52:15 -08:00 committed by Junio C Hamano
parent da72936f54
commit 8cb7980382

View File

@ -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
'