Re: [PATCH 11/12] t0610: fix non-portable variable assignment
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Apr 5, 2024, 09:14 UTC
- Message-ID
- <CAPig+cSb_cKXYaNCBpe9Uy_iGB_K2NXaw4d1hg5bPuVaCEWvjA@mail.gmail.com>
- In-Reply-To
- <c2c2747ff57f68ccad8b509af037e1fc4a524fa1.1712235356.git.ps@pks.im>
On Fri, Apr 5, 2024 at 3:51 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 6 quoted lines
> In `test_expect_perms()` we assign the output of a command to a variable > declared via `local`. To assert that the command is actually successful > we also chain it with `&&`. This construct is seemingly not portable and > may fail with "local: 1: bad variable name". > > Split up the variable declaration and assignment to fix this.
Under what configuration, circumstances, conditions did you encounter this problem? I ask because this isn't the only such case in the test suite, as shown by:
git grep -nP 'local ..*=\$\(..*&&' -- t
What makes this case distinct from the others? Including such information would improve the commit message and help future readers.
Show 11 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
> @@ -80,8 +80,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 actual
>
> + actual=$(ls -l "$file") &&