Skip to content

Commit db8c7a1

Browse files
sunshinecogitster
authored andcommitted
chainlint.sed: improve ?!AMP?! placement accuracy
When chainlint.sed detects a broken &&-chain, it places an ?!AMP?! 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 ?!AMP?! annotation to the end of the line 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 f30c1d5 commit db8c7a1

23 files changed

+38
-38
lines changed

t/chainlint.sed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ s/.*\n//
236236
# line ends with pipe "...|" -- valid; not missing "&&"
237237
/|[ ]*$/bcont
238238
# missing end-of-line "&&" -- mark suspect
239-
/&&[ ]*$/!s/^/?!AMP?!/
239+
/&&[ ]*$/!s/$/ ?!AMP?!/
240240
:cont
241241
# retrieve and print previous line
242242
x
@@ -303,15 +303,15 @@ bcase
303303
# that line legitimately lacks "&&"
304304
:else
305305
x
306-
s/?!AMP?!//
306+
s/ ?!AMP?!$//
307307
x
308308
bcont
309309

310310
# found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
311311
# "suspect" from final contained line since that line legitimately lacks "&&"
312312
:done
313313
x
314-
s/?!AMP?!//
314+
s/ ?!AMP?!$//
315315
x
316316
# is 'done' or 'fi' cuddled with ")" to close subshell?
317317
/done.*)/bclose
@@ -354,7 +354,7 @@ bblock
354354
# since that line legitimately lacks "&&" and exit subshell loop
355355
:clssolo
356356
x
357-
s/?!AMP?!//
357+
s/ ?!AMP?!$//
358358
p
359359
x
360360
s/^/>/

t/chainlint/arithmetic-expansion.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
baz
55
>) &&
66
(
7-
?!AMP?! bar=$((42 + 1))
7+
bar=$((42 + 1)) ?!AMP?!
88
baz
99
>)

t/chainlint/block.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
bar &&
88
{
99
echo c
10-
?!AMP?! }
10+
} ?!AMP?!
1111
baz
1212
>)

t/chainlint/broken-chain.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(
22
foo &&
3-
?!AMP?! bar
3+
bar ?!AMP?!
44
baz &&
55
wop
66
>)

t/chainlint/case.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
case "$x" in
1010
x) foo ;;
1111
*) bar ;;
12-
?!AMP?! esac
12+
esac ?!AMP?!
1313
foobar
1414
>) &&
1515
(
1616
case "$x" in 1) true;; esac &&
17-
?!AMP?! case "$y" in 2) false;; esac
17+
case "$y" in 2) false;; esac ?!AMP?!
1818
foobar
1919
>)

t/chainlint/command-substitution.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
baz
55
>) &&
66
(
7-
?!AMP?! bar=$(gobble blocks)
7+
bar=$(gobble blocks) ?!AMP?!
88
baz
99
>)

t/chainlint/cuddled.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cd foo &&
44
>) &&
55

66
(
7-
?!AMP?!cd foo
7+
cd foo ?!AMP?!
88
bar
99
>) &&
1010

@@ -17,5 +17,5 @@ cd foo &&
1717
> bar) &&
1818

1919
(
20-
?!AMP?!cd foo
20+
cd foo ?!AMP?!
2121
> bar)

t/chainlint/for-loop.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(
22
for i in a b c
33
do
4-
?!AMP?! echo $i
4+
echo $i ?!AMP?!
55
cat
6-
?!AMP?! done
6+
done ?!AMP?!
77
for i in a b c; do
88
echo $i &&
99
cat $i
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(
22
x=$(bobble &&
3-
?!AMP?!>> wiffle)
3+
>> wiffle) ?!AMP?!
44
echo $x
55
>)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(
2-
?!AMP?! cat && echo "multi-line string"
2+
cat && echo "multi-line string" ?!AMP?!
33
bap
44
>)

0 commit comments

Comments
 (0)