Junio C Hamano <gitster@xxxxxxxxx> writes: > Rubén Justo <rjusto@xxxxxxxxx> writes: > >> The common construct: >> >> VAR=VAL command args >> >> it's a common way to define one-shot variables within the scope of >> executing a "command". > > "it's a" -> "is a". > "define" -> "set and export". > >> However, when "command" is a function which in turn executes the >> "command", the behavior varies depending on the shell: >> >> ** Bash 5.2.21 ** >> >> $ f () { bash -c 'echo A=$A'; } >> $ A=1 f >> A=1 >> >> ** dash 0.5.12-9 ** >> >> $ f () { bash -c 'echo A=$A'; } >> $ A=1 f >> A=1 >> >> ** dash 0.5.10.2-6 ** >> >> $ f () { bash -c 'echo A=$A'; } >> $ A=1 f >> A= Another thing. Let's insert a paragraph perhaps like this here. Note that POSIX explicitly says the effect of this construct used on a shell function is unspecified. >> One of our CI jobs on GitHub Actions uses Ubuntu 20.04 running dash >> 0.5.10.2-6, so we failed the test t3701:51; the "git add -p" being >> tested did not get our custom GIT_PAGER, which broke the test. >> >> Work it around by explicitly exporting the variable in a subshell. That way, we won't give a wrong impression that we can safely start using the construct in future once dash 0.5.10.2-6 goes away.