chainlint.sed: improve ?!SEMI?! placement accuracy

When chainlint.sed detects commands separated by a semicolon rather than by `&&`, it places a ?!SEMI?! annotation at the beginning of the line. However, this is an unusual location for programmers accustomed to error messages (from compilers, for instance) indicating the exact point of the problem. Therefore, relocate the ?!SEMI?! annotation to the location of the semicolon in order to better direct the programmer's attention to the source of the problem. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Dec 13, 2021 at 01:30 UTC fbd992b61b3acb6ce235d678bfe65a60c503dddd
5 files changed +18 -18
t/chainlint.sed
+2 -2
index 883a2b307c..60c2099c18 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -126,7 +126,7 @@ b # "&&" (but not ";" in a string) :oneline /;/{ - /"[^"]*;[^"]*"/!s/^/?!SEMI?!/ + /"[^"]*;[^"]*"/!s/;/; ?!SEMI?!/ } b @@ -230,7 +230,7 @@ s/.*\n// # string and not ";;" in one-liner "case...esac") /;/{ /;;/!{ - /"[^"]*;[^"]*"/!s/^/?!SEMI?!/ + /"[^"]*;[^"]*"/!s/;/; ?!SEMI?!/ } } # line ends with pipe "...|" -- valid; not missing "&&"
t/chainlint/negated-one-liner.expect
+2 -2
index cf18429d03..60baf84b7a 100644 --- a/t/chainlint/negated-one-liner.expect +++ b/t/chainlint/negated-one-liner.expect @@ -1,5 +1,5 @@ ! (foo && bar) && ! (foo && bar) >baz && -?!SEMI?!! (foo; bar) && -?!SEMI?!! (foo; bar) >baz +! (foo; ?!SEMI?! bar) && +! (foo; ?!SEMI?! bar) >baz
t/chainlint/one-liner.expect
+3 -3
index c64058f7af..3b46554728 100644 --- a/t/chainlint/one-liner.expect +++ b/t/chainlint/one-liner.expect @@ -2,8 +2,8 @@ (foo && bar) | (foo && bar) >baz && -?!SEMI?!(foo; bar) && -?!SEMI?!(foo; bar) | -?!SEMI?!(foo; bar) >baz && +(foo; ?!SEMI?! bar) && +(foo; ?!SEMI?! bar) | +(foo; ?!SEMI?! bar) >baz && (foo "bar; baz")
t/chainlint/semicolon.expect
+7 -7
index ffc87bdffb..d2d804f5b0 100644 --- a/t/chainlint/semicolon.expect +++ b/t/chainlint/semicolon.expect @@ -1,20 +1,20 @@ ( -?!SEMI?! cat foo ; echo bar ?!AMP?! -?!SEMI?! cat foo ; echo bar + cat foo ; ?!SEMI?! echo bar ?!AMP?! + cat foo ; ?!SEMI?! echo bar >) && ( -?!SEMI?! cat foo ; echo bar && -?!SEMI?! cat foo ; echo bar + cat foo ; ?!SEMI?! echo bar && + cat foo ; ?!SEMI?! echo bar >) && ( echo "foo; bar" && -?!SEMI?! cat foo; echo bar + cat foo; ?!SEMI?! echo bar >) && ( -?!SEMI?! foo; + foo; ?!SEMI?! >) && ( cd foo && for i in a b c; do -?!SEMI?! echo; + echo; ?!SEMI?! > done)
t/chainlint/subshell-one-liner.expect
+4 -4
index ec77aa5b95..432217801b 100644 --- a/t/chainlint/subshell-one-liner.expect +++ b/t/chainlint/subshell-one-liner.expect @@ -2,13 +2,13 @@ (foo && bar) && (foo && bar) | (foo && bar) >baz && -?!SEMI?! (foo; bar) && -?!SEMI?! (foo; bar) | -?!SEMI?! (foo; bar) >baz && + (foo; ?!SEMI?! bar) && + (foo; ?!SEMI?! bar) | + (foo; ?!SEMI?! bar) >baz && (foo || exit 1) && (foo || exit 1) | (foo || exit 1) >baz && (foo && bar) ?!AMP?! -?!SEMI?! (foo && bar; baz) ?!AMP?! + (foo && bar; ?!SEMI?! baz) ?!AMP?! foobar >)