]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/chainlint.pl
chainlint.pl: don't flag broken &&-chain if `$?` handled explicitly
[thirdparty/git.git] / t / chainlint.pl
index ba3fcb0c8e613be4b02a2a564d9dd899fe136ad1..14e1db3519a2d55d966412934102795d50e6e06b 100755 (executable)
@@ -497,6 +497,12 @@ sub accumulate {
        # did previous command end with "&&", "|", "|| return" or similar?
        goto DONE if match_ending($tokens, \@safe_endings);
 
+       # if this command handles "$?" specially, then okay for previous
+       # command to be missing "&&"
+       for my $token (@$cmd) {
+               goto DONE if $token =~ /\$\?/;
+       }
+
        # flag missing "&&" at end of previous command
        my $n = find_non_nl($tokens);
        splice(@$tokens, $n + 1, 0, '?!AMP?!') unless $n < 0;