]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/check-non-portable-shell: detect "FOO= shell_func", too
authorJonathan Nieder <jrnieder@gmail.com>
Thu, 26 Dec 2019 19:57:47 +0000 (11:57 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jan 2020 22:02:32 +0000 (14:02 -0800)
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 <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/check-non-portable-shell.pl

index 38bfeebd881ae8930d965536a42305771b066477..fd3303552bec0d3ca243845634179eb35890866a 100755 (executable)
@@ -46,7 +46,7 @@ while (<>) {
        /(?:\$\(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