From 22e3e0241ab5add065411d0d8d493f066764465e Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 13 Aug 2018 04:47:38 -0400 Subject: chainlint: recognize multi-line quoted strings more robustly chainlint.sed recognizes multi-line quoted strings within subshells: echo "abc def" >out && so it can avoid incorrectly classifying lines internal to the string as breaking the &&-chain. To identify the first line of a multi-line string, it checks if the line contains a single quote. However, this is fragile and can be easily fooled by a line containing multiple strings: echo "xyz" "abc def" >out && Make detection more robust by checking for an odd number of quotes rather than only a single one. (Escaped quotes are not handled, but support may be added later.) The original multi-line string recognizer rather cavalierly threw away all but the final quote, whereas the new one is careful to retain all quotes, so the "expected" output of a couple existing chainlint tests is updated to account for this new behavior. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/chainlint/multi-line-string.expect | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 't/chainlint/multi-line-string.expect') diff --git a/t/chainlint/multi-line-string.expect b/t/chainlint/multi-line-string.expect index 8334c4cc8e..170cb59993 100644 --- a/t/chainlint/multi-line-string.expect +++ b/t/chainlint/multi-line-string.expect @@ -1,9 +1,15 @@ ( - x=line 1 line 2 line 3" && -?!AMP?! y=line 1 line2' + x="line 1 line 2 line 3" && +?!AMP?! y='line 1 line2' foobar >) && ( echo "there's nothing to see here" && exit +>) && +( + echo "xyz" "abc def ghi" && + echo 'xyz' 'abc def ghi' && + echo 'xyz' "abc def ghi" && + barfoo >) -- cgit v1.2.3