chainlint.sed: tolerate harmless ";" at end of last line in block
chainlint.sed flags ";" when used as a command terminator since it breaks the &&-chain, thus can allow failures to go undetected. However, when a command terminated by ";" is the last command in the body of a compound statement, such as `command-2` in: if test $# -gt 1 then command-1 && command-2; fi then the ";" is harmless and the exit code from `command-2` is passed through untouched and becomes the exit code of the compound statement, as if the ";" was not present. Therefore, tolerate a trailing ";" in this position rather than complaining about broken &&-chain. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fbd992b61b
commit
3865a7e36d
@ -47,8 +47,9 @@
|
|||||||
# "?!AMP?!" violation is removed from the "bar" line (retrieved from the "hold"
|
# "?!AMP?!" violation is removed from the "bar" line (retrieved from the "hold"
|
||||||
# area) since the final statement of a subshell must not end with "&&". The
|
# area) since the final statement of a subshell must not end with "&&". The
|
||||||
# final line of a subshell may still break the &&-chain by using ";" internally
|
# final line of a subshell may still break the &&-chain by using ";" internally
|
||||||
# to chain commands together rather than "&&", so "?!SEMI?!" is never removed
|
# to chain commands together rather than "&&", so "?!SEMI?!" is not removed
|
||||||
# from a line (even though "?!AMP?!" might be).
|
# from such a line; however, if the line ends with "?!SEMI?!", then the ";" is
|
||||||
|
# harmless and the annotation is removed.
|
||||||
#
|
#
|
||||||
# Care is taken to recognize the last _statement_ of a multi-line subshell, not
|
# Care is taken to recognize the last _statement_ of a multi-line subshell, not
|
||||||
# necessarily the last textual _line_ within the subshell, since &&-chaining
|
# necessarily the last textual _line_ within the subshell, since &&-chaining
|
||||||
@ -303,7 +304,7 @@ bcase
|
|||||||
# that line legitimately lacks "&&"
|
# that line legitimately lacks "&&"
|
||||||
:else
|
:else
|
||||||
x
|
x
|
||||||
s/ ?!AMP?!$//
|
s/\( ?!SEMI?!\)* ?!AMP?!$//
|
||||||
x
|
x
|
||||||
bcont
|
bcont
|
||||||
|
|
||||||
@ -311,7 +312,7 @@ bcont
|
|||||||
# "suspect" from final contained line since that line legitimately lacks "&&"
|
# "suspect" from final contained line since that line legitimately lacks "&&"
|
||||||
:done
|
:done
|
||||||
x
|
x
|
||||||
s/ ?!AMP?!$//
|
s/\( ?!SEMI?!\)* ?!AMP?!$//
|
||||||
x
|
x
|
||||||
# is 'done' or 'fi' cuddled with ")" to close subshell?
|
# is 'done' or 'fi' cuddled with ")" to close subshell?
|
||||||
/done.*)/bclose
|
/done.*)/bclose
|
||||||
@ -354,7 +355,7 @@ bblock
|
|||||||
# since that line legitimately lacks "&&" and exit subshell loop
|
# since that line legitimately lacks "&&" and exit subshell loop
|
||||||
:clssolo
|
:clssolo
|
||||||
x
|
x
|
||||||
s/ ?!AMP?!$//
|
s/\( ?!SEMI?!\)* ?!AMP?!$//
|
||||||
p
|
p
|
||||||
x
|
x
|
||||||
s/^/>/
|
s/^/>/
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
cat foo; ?!SEMI?! echo bar
|
cat foo; ?!SEMI?! echo bar
|
||||||
>) &&
|
>) &&
|
||||||
(
|
(
|
||||||
foo; ?!SEMI?!
|
foo;
|
||||||
>) &&
|
>) &&
|
||||||
(
|
(
|
||||||
cd foo &&
|
cd foo &&
|
||||||
for i in a b c; do
|
for i in a b c; do
|
||||||
echo; ?!SEMI?!
|
echo;
|
||||||
> done)
|
> done)
|
||||||
|
Loading…
Reference in New Issue
Block a user