Skip to content

Commit a7fbf12

Browse files
jrngitster
authored andcommitted
t/check-non-portable-shell: detect "FOO= shell_func", too
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]>
1 parent c7973f2 commit a7fbf12

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
@@ -46,7 +46,7 @@ sub err {
4646
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
4747
/\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)';
4848
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
49-
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
49+
/^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
5050
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
5151
$line = '';
5252
# this resets our $. for each file

0 commit comments

Comments
 (0)