Skip to content

Commit fbd992b

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent db8c7a1 commit fbd992b

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

t/chainlint.sed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ b
126126
# "&&" (but not ";" in a string)
127127
:oneline
128128
/;/{
129-
/"[^"]*;[^"]*"/!s/^/?!SEMI?!/
129+
/"[^"]*;[^"]*"/!s/;/; ?!SEMI?!/
130130
}
131131
b
132132

@@ -230,7 +230,7 @@ s/.*\n//
230230
# string and not ";;" in one-liner "case...esac")
231231
/;/{
232232
/;;/!{
233-
/"[^"]*;[^"]*"/!s/^/?!SEMI?!/
233+
/"[^"]*;[^"]*"/!s/;/; ?!SEMI?!/
234234
}
235235
}
236236
# line ends with pipe "...|" -- valid; not missing "&&"

t/chainlint/negated-one-liner.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! (foo && bar) &&
22
! (foo && bar) >baz &&
33

4-
?!SEMI?!! (foo; bar) &&
5-
?!SEMI?!! (foo; bar) >baz
4+
! (foo; ?!SEMI?! bar) &&
5+
! (foo; ?!SEMI?! bar) >baz

t/chainlint/one-liner.expect

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
(foo && bar) |
33
(foo && bar) >baz &&
44

5-
?!SEMI?!(foo; bar) &&
6-
?!SEMI?!(foo; bar) |
7-
?!SEMI?!(foo; bar) >baz &&
5+
(foo; ?!SEMI?! bar) &&
6+
(foo; ?!SEMI?! bar) |
7+
(foo; ?!SEMI?! bar) >baz &&
88

99
(foo "bar; baz")

t/chainlint/semicolon.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
(
2-
?!SEMI?! cat foo ; echo bar ?!AMP?!
3-
?!SEMI?! cat foo ; echo bar
2+
cat foo ; ?!SEMI?! echo bar ?!AMP?!
3+
cat foo ; ?!SEMI?! echo bar
44
>) &&
55
(
6-
?!SEMI?! cat foo ; echo bar &&
7-
?!SEMI?! cat foo ; echo bar
6+
cat foo ; ?!SEMI?! echo bar &&
7+
cat foo ; ?!SEMI?! echo bar
88
>) &&
99
(
1010
echo "foo; bar" &&
11-
?!SEMI?! cat foo; echo bar
11+
cat foo; ?!SEMI?! echo bar
1212
>) &&
1313
(
14-
?!SEMI?! foo;
14+
foo; ?!SEMI?!
1515
>) &&
1616
(
1717
cd foo &&
1818
for i in a b c; do
19-
?!SEMI?! echo;
19+
echo; ?!SEMI?!
2020
> done)

t/chainlint/subshell-one-liner.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
(foo && bar) &&
33
(foo && bar) |
44
(foo && bar) >baz &&
5-
?!SEMI?! (foo; bar) &&
6-
?!SEMI?! (foo; bar) |
7-
?!SEMI?! (foo; bar) >baz &&
5+
(foo; ?!SEMI?! bar) &&
6+
(foo; ?!SEMI?! bar) |
7+
(foo; ?!SEMI?! bar) >baz &&
88
(foo || exit 1) &&
99
(foo || exit 1) |
1010
(foo || exit 1) >baz &&
1111
(foo && bar) ?!AMP?!
12-
?!SEMI?! (foo && bar; baz) ?!AMP?!
12+
(foo && bar; ?!SEMI?! baz) ?!AMP?!
1313
foobar
1414
>)

0 commit comments

Comments
 (0)