Skip to content

Commit

Permalink
t/check-non-portable-shell: detect "FOO= shell_func", too
Browse files Browse the repository at this point in the history
Just like assigning a nonempty value, assigning an empty value to a
shell variable when calling a function produces non-portable behavior:
in some shells, the assignment lasts for the duration of the function
invocation, and in others, it persists after the function returns.

Signed-off-by: Jonathan Nieder <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
jrn authored and gitster committed Jan 15, 2020
1 parent c7973f2 commit a7fbf12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion t/check-non-portable-shell.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sub err {
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
/\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)';
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
/^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
$line = '';
# this resets our $. for each file
Expand Down

0 comments on commit a7fbf12

Please sign in to comment.