summaryrefslogtreecommitdiff
path: root/t/chainlint
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2018-08-13 08:47:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-13 19:22:12 (GMT)
commit22e3e0241ab5add065411d0d8d493f066764465e (patch)
treec0b2b77d4071eeab6b5c83bc3aff098b7159c64c /t/chainlint
parentd93871143fdb7c11ddea81aa7f698e5eee0246e5 (diff)
downloadgit-22e3e0241ab5add065411d0d8d493f066764465e.zip
git-22e3e0241ab5add065411d0d8d493f066764465e.tar.gz
git-22e3e0241ab5add065411d0d8d493f066764465e.tar.bz2
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 <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/chainlint')
-rw-r--r--t/chainlint/here-doc-multi-line-string.expect2
-rw-r--r--t/chainlint/multi-line-string.expect10
-rw-r--r--t/chainlint/multi-line-string.test12
3 files changed, 21 insertions, 3 deletions
diff --git a/t/chainlint/here-doc-multi-line-string.expect b/t/chainlint/here-doc-multi-line-string.expect
index 1e5b724..32038a0 100644
--- a/t/chainlint/here-doc-multi-line-string.expect
+++ b/t/chainlint/here-doc-multi-line-string.expect
@@ -1,4 +1,4 @@
(
-?!AMP?! cat && echo multi-line string"
+?!AMP?! cat && echo "multi-line string"
bap
>)
diff --git a/t/chainlint/multi-line-string.expect b/t/chainlint/multi-line-string.expect
index 8334c4c..170cb59 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
>)
diff --git a/t/chainlint/multi-line-string.test b/t/chainlint/multi-line-string.test
index 14cb44d..287ab89 100644
--- a/t/chainlint/multi-line-string.test
+++ b/t/chainlint/multi-line-string.test
@@ -12,4 +12,16 @@
# LINT: starting multi-line single-quoted string
echo "there's nothing to see here" &&
exit
+) &&
+(
+ echo "xyz" "abc
+ def
+ ghi" &&
+ echo 'xyz' 'abc
+ def
+ ghi' &&
+ echo 'xyz' "abc
+ def
+ ghi" &&
+ barfoo
)