Skip to content

Commit 7bd0cd0

Browse files
sunshinecogitster
authored andcommitted
check-non-portable-shell: suggest alternative for VAR=val shell-func
Most problems reported by check-non-portable-shell are accompanied by advice suggesting how the test author can repair the problem. For instance: error: egrep/fgrep obsolescent (use grep -E/-F) However, when one-shot variable assignment is detected when calling a shell function (i.e. `VAR=val shell-func`), the problem is reported, but no advice is given. The lack of advice is particularly egregious since neither the problem nor the workaround are likely well-known by newcomers to the project writing tests for the first time. Address this shortcoming by recommending the use of `test_env` which is tailor made for this specific use-case. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a7fa609 commit 7bd0cd0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/check-non-portable-shell.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sub err {
5050
/\blocal\s+[A-Za-z0-9_]*=\$([A-Za-z0-9_{]|[(][^(])/ and
5151
err q(quote "$val" in 'local var=$val');
5252
/^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
53-
err '"FOO=bar shell_func" is not portable';
53+
err '"FOO=bar shell_func" is not portable (use test_env FOO=bar shell_func)';
5454
$line = '';
5555
# this resets our $. for each file
5656
close ARGV if eof;

0 commit comments

Comments
 (0)