aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2024-07-27 01:35:07 -0400
committerJunio C Hamano <gitster@pobox.com>2024-07-26 22:49:40 -0700
commita7fa6097473e42b3547cf59fb52fd5ff34e9bd48 (patch)
treee30894db7ea85b84dfc5821162bd36e0b4807b0c
parent5e91056a1b0d38c6b2149c2c3a72198720a1867f (diff)
downloadgit-a7fa6097473e42b3547cf59fb52fd5ff34e9bd48.tar.gz
check-non-portable-shell: loosen one-shot assignment error message
When a0a630192d (t/check-non-portable-shell: detect "FOO=bar shell_func", 2018-07-13) added the check for one-shot environment variable assignment for shell functions, the primary reason given for avoiding them was that, under some shells, the assignment outlives the invocation of the shell function, thus could potentially negatively impact subsequent commands in the same test, as well as subsequent tests. However, it has recently become apparent that this is not the only potential problem with one-shot assignments and shell functions. Another problem is that some shells do not actually export the variable to commands which the function invokes[1]. More significantly, however, the behavior of one-shot assignments with shell functions is not specified by POSIX[2]. Given this new understanding, the presented error message ("assignment extends beyond 'shell_func'") is too specific and potentially misleading. Address this by emitting a less specific error message. (Note that the wording "is not portable" is chosen over the more specific "behavior not specified by POSIX" for consistency with almost all other error message issued by this "lint" script.) [1]: https://lore.kernel.org/git/xmqqbk2p9lwi.fsf_-_@gitster.g/ [2]: https://lore.kernel.org/git/xmqq34o19jj1.fsf@gitster.g/ Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/check-non-portable-shell.pl2
1 files changed, 1 insertions, 1 deletions
diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl
index b2b28c2ced..179efaa39d 100755
--- a/t/check-non-portable-shell.pl
+++ b/t/check-non-portable-shell.pl
@@ -50,7 +50,7 @@ while (<>) {
/\blocal\s+[A-Za-z0-9_]*=\$([A-Za-z0-9_{]|[(][^(])/ and
err q(quote "$val" in 'local var=$val');
/^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
- err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
+ err '"FOO=bar shell_func" is not portable';
$line = '';
# this resets our $. for each file
close ARGV if eof;