git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] shell: local x=$1 may need to quote the RHS

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 26, 2022, 05:53 UTC
Message-ID
<xmqqo83zt54a.fsf@gitster.g>
In-Reply-To
<YfBbRca0Rjl59MM0@nand.local>
Taylor Blau <me@ttaylorr.com> writes:
Show 20 quoted lines
> Yeah; bisecting dash with your example script pointed me at cbb71a8
> (eval: Add assignment built-in support again, 2018-05-19), which indeed
> appears in v0.5.11 (and all subsequent versions).
>
> cbb71a8 points at release 0.3.8-15, which predates Git (and a tag
> pointing at it was never created, since it's behind the big "initial
> import" commit at the beginning of dash.git's history). But skimming
> ChangeLog.O, we see:
>
>     * Removed assignment builtins since it is at best undefined by the
>       SuS and also can't be implemented consistently.
>
> So this probably didn't work at all between that 0.3.8-15 up until v0.5.11.
>
>> The manual page for recent dash may need an update.
>> Can you perhaps file a bug on their documentation?
>
> Yes, I agree that dash.1 is out-of-date after cbb71a8. Konstantin:
> please feel free to use any of this if it's helpful to you in creating a
> bug report for the dash folks.

I doubt that we can write off dash v0.5.10 as too old to matter, as the tagger date seems to be mid 2020 at

https://kernel.googlesource.com/pub/scm/utils/dash/dash/+/refs/tags/v0.5.11
So here is a bit wider "grep" output, looking for
$ git grep '^[ 	]*local[	 ].*=' \*.sh

to reject _any_ assignment on the same line as "local", but I manually excluded the ones that are not meant to be run with dash. I obviously excluded the one in t0000 (try_local_xy) that is a weather-balloon for this exact issue.

According to this thread, these would not work correctly on dash older than 0.5.11 and needs fixing by splitting declaration of variables as locals and assignment of their initial values.

contrib/subtree/git-subtree.sh: local indent=$(($indent + 1)) contrib/subtree/git-subtree.sh: local indent=$(($indent + 1)) contrib/subtree/git-subtree.sh: local indent=$(($indent + 1)) contrib/subtree/git-subtree.sh: local grep_format="^git-subtree-dir: $dir/*\$" contrib/subtree/git-subtree.sh: local rev="$1" contrib/subtree/git-subtree.sh: local parents="$2" contrib/subtree/git-subtree.sh: local indent=$(($indent + 1)) t/lib-parallel-checkout.sh: local expected_workers=$1 && t/lib-parallel-checkout.sh: local trace_file=trace-test-checkout-workers && t/lib-parallel-checkout.sh: local workers="$(grep "child_start\[..*\] git checkout--worker" "$trace_file" | wc -l)" && t/t0021-conversion.sh: local expect_progress=N && t/t0021-conversion.sh: local expect_progress= t/t3435-rebase-gpg-sign.sh: local must_fail= will=will fake_editor= t/t3514-cherry-pick-revert-gpg.sh: local must_fail= will=will fake_editor= t/t4011-diff-symlink.sh: local oid=$(printf "%s" "$1" | git hash-object --stdin) && t/t4011-diff-symlink.sh: local oid=$(git hash-object "$1") && t/t4210-log-i18n.sh: local engine=$1 t/t4210-log-i18n.sh: local pattern=$1 t/t6006-rev-list-format.sh: local args= t/t6006-rev-list-format.sh: local args= t/t9902-completion.sh: local IFS=$'\n' t/t9902-completion.sh: local cur="$1" && t/t9902-completion.sh: local cur="$1" && t/t9902-completion.sh: local cur="$1" expected="$2" t/test-lib-functions.sh: local op='=' wrong_result=different t/test-lib-functions.sh: local test_cmp_a= test_cmp_b= t/test-lib-functions.sh: local stdin_for_diff= t/test-lib-functions.sh: local algo="${test_hash_algo}" && t/test-lib-functions.sh: local var="test_oid_${algo}_$1" && t/test-lib-functions.sh: local basename=${1#??} t/test-lib-functions.sh: local var=$1 port t/test-lib-functions.sh: local negate= t/test-lib-functions.sh: local expr=$(printf '"%s",' "$@") t/test-lib-functions.sh: local negate= t/test-lib-functions.sh: local expr=$(printf '"%s".*' "$@") t/test-lib-functions.sh: local expect_exit=0 t/test-lib.sh: local opt="$1" t/test-lib.sh: local bail_out="Bail out! " t/test-lib.sh: local message="$1"

Previous: Taylor BlauNext: Konstantin Khomoutov
Message 5 of 9 in “[RFC] shell: local x=$1 may need to quote the RHS”
  1. Junio C HamanoJan 24, 2022
  2. Konstantin KhomoutovJan 25, 2022
  3. Junio C HamanoJan 25, 2022
  4. Taylor BlauJan 25, 2022
  5. Junio C HamanoJan 26, 2022
  6. Konstantin KhomoutovJan 26, 2022
  7. SZEDER GáborJan 26, 2022
  8. Taylor BlauJan 26, 2022
  9. Junio C HamanoJan 27, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.