Re: [PATCH 11/12] t0610: fix non-portable variable assignment
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 5, 2024, 16:02 UTC
- Message-ID
- <xmqqmsq7yezc.fsf@gitster.g>
- In-Reply-To
- <c2c2747ff57f68ccad8b509af037e1fc4a524fa1.1712235356.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 7 quoted lines
> test_expect_perms () {
> local perms="$1"
> local file="$2"
> - local actual=$(ls -l "$file") &&
> + local actual
>
> + actual=$(ls -l "$file") &&Isn't this the same as what ebee5580 (parallel-checkout: avoid dash local bug in tests, 2021-06-06) fixed?
The rule for variable assignment is mishandled when local is involved by some shells.
perms=$1 file=$2 actual=$(ls -l "$file")
would be perfectly fine, and should be fine with "local" prefixed on these lines, but the last one with local without "" qround $(...) incorrectly makes the substitution subject to field splitting.
I think the right fix should look rather like this, instead.
t/t0610-reftable-basics.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git i/t/t0610-reftable-basics.sh w/t/t0610-reftable-basics.sh index 686781192e..894896933e 100755 --- i/t/t0610-reftable-basics.sh +++ w/t/t0610-reftable-basics.sh @@ -81,9 +81,9 @@ test_expect_success 'init: reinitializing reftable with files backend fails' ' ' test_expect_perms () { - local perms="$1" - local file="$2" - local actual=$(ls -l "$file") && + local perms="$1" && + local file="$2" && + local actual="$(ls -l "$file")" && case "$actual" in $perms*)