chainlint.sed: drop subshell-closing ">" annotation

chainlint.sed inserts a ">" annotation at the beginning of a line to signal that its heuristics have identified an end-of-subshell. This was useful as a debugging aid during development of the script, but it has no value to test writers and might even confuse them into thinking that the linter is misbehaving by inserting line-noise into the shell code it is validating. Moreover, its presence also potentially makes it difficult to reuse the chainlint self-test "expect" output should a more capable linter ever be developed. Therefore, drop the ">" annotation. 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 5be30d0cd301f50e5f4dd992bc11ce75f457cf46
39 files changed +80 -89
t/chainlint.sed
-9
@@ -76,12 +76,6 @@
76 # newline, thus the closing here-doc tag has been found. The closing tag line
77 # and the "<...>" prefix on the target line are then discarded, leaving just
78 # the target line "cat >out".
79 -#
80 -# To facilitate regression testing (and manual debugging), a ">" annotation is
81 -# applied to the line containing ")" which closes a subshell, ">>" to a line
82 -# closing a nested subshell, and ">>>" to a line closing both at once. This
83 -# makes it easy to detect whether the heuristics correctly identify
84 -# end-of-subshell.
79 #------------------------------------------------------------------------------
80
81 # incomplete line -- slurp up next line
@@ -337,7 +331,6 @@ n
331 x
332 bnstslrp
333 :nstcl
340 -s/^/>>/
334 # is it "))" which closes nested and parent subshells?
335 /)[ ]*)/bslurp
336 bchkchn
@@ -357,7 +350,6 @@ x
350 s/\( ?!AMP?!\)* ?!AMP?!$//
351 p
352 x
360 -s/^/>/
353 b
354
355 # found closing "...)" -- exit subshell loop
@@ -365,5 +357,4 @@ b
357 x
358 p
359 x
368 -s/^/>/
360 b
t/chainlint/arithmetic-expansion.expect
+2 -2
@@ -2,8 +2,8 @@
2 foo &&
3 bar=$((42 + 1)) &&
4 baz
5 ->) &&
5 +) &&
6 (
7 bar=$((42 + 1)) ?!AMP?!
8 baz
9 ->)
9 +)
t/chainlint/bash-array.expect
+2 -2
@@ -2,9 +2,9 @@
2 foo &&
3 bar=(gumbo stumbo wumbo) &&
4 baz
5 ->) &&
5 +) &&
6 (
7 foo &&
8 bar=${#bar[@]} &&
9 baz
10 ->)
10 +)
t/chainlint/blank-line.expect
+1 -1
@@ -1,4 +1,4 @@
1 (
2 nothing &&
3 something
4 ->)
4 +)
t/chainlint/block.expect
+1 -1
@@ -9,4 +9,4 @@
9 echo c
10 } ?!AMP?!
11 baz
12 ->)
12 +)
t/chainlint/broken-chain.expect
+1 -1
@@ -3,4 +3,4 @@
3 bar ?!AMP?!
4 baz &&
5 wop
6 ->)
6 +)
t/chainlint/case.expect
+3 -3
@@ -4,16 +4,16 @@
4 *) bar ;;
5 esac &&
6 foobar
7 ->) &&
7 +) &&
8 (
9 case "$x" in
10 x) foo ;;
11 *) bar ;;
12 esac ?!AMP?!
13 foobar
14 ->) &&
14 +) &&
15 (
16 case "$x" in 1) true;; esac &&
17 case "$y" in 2) false;; esac ?!AMP?!
18 foobar
19 ->)
19 +)
t/chainlint/close-nested-and-parent-together.expect
+1 -1
@@ -1,4 +1,4 @@
1 (
2 cd foo &&
3 (bar &&
4 ->>> baz))
4 + baz))
t/chainlint/close-subshell.expect
+8 -8
@@ -1,25 +1,25 @@
1 (
2 foo
3 ->) &&
3 +) &&
4 (
5 bar
6 ->) >out &&
6 +) >out &&
7 (
8 baz
9 ->) 2>err &&
9 +) 2>err &&
10 (
11 boo
12 ->) <input &&
12 +) <input &&
13 (
14 bip
15 ->) | wuzzle &&
15 +) | wuzzle &&
16 (
17 bop
18 ->) | fazz fozz &&
18 +) | fazz fozz &&
19 (
20 bup
21 ->) |
21 +) |
22 fuzzle &&
23 (
24 yop
25 ->)
25 +)
t/chainlint/command-substitution.expect
+2 -2
@@ -2,8 +2,8 @@
2 foo &&
3 bar=$(gobble) &&
4 baz
5 ->) &&
5 +) &&
6 (
7 bar=$(gobble blocks) ?!AMP?!
8 baz
9 ->)
9 +)
t/chainlint/comment.expect
+1 -1
@@ -1,4 +1,4 @@
1 (
2 nothing &&
3 something
4 ->)
4 +)
t/chainlint/complex-if-in-cuddled-loop.expect
+1 -1
@@ -6,5 +6,5 @@ for i in a b c; do
6 else
7 echo >file
8 fi
9 -> done) &&
9 + done) &&
10 test ! -f file
t/chainlint/cuddled-if-then-else.expect
+1 -1
@@ -3,5 +3,5 @@ if test -z ""; then
3 echo empty
4 else
5 echo bizzy
6 -> fi) &&
6 + fi) &&
7 echo foobar
t/chainlint/cuddled-loop.expect
+1 -1
@@ -1,5 +1,5 @@
1 (
2 while read x
3 do foobar bop || exit 1
4 -> done <file ) &&
4 + done <file ) &&
5 outside subshell
t/chainlint/cuddled.expect
+5 -5
@@ -1,21 +1,21 @@
1 (
2 cd foo &&
3 bar
4 ->) &&
4 +) &&
5
6 (
7 cd foo ?!AMP?!
8 bar
9 ->) &&
9 +) &&
10
11 (
12 cd foo &&
13 -> bar) &&
13 + bar) &&
14
15 (
16 cd foo &&
17 -> bar) &&
17 + bar) &&
18
19 (
20 cd foo ?!AMP?!
21 -> bar)
21 + bar)
t/chainlint/exit-loop.expect
+3 -3
@@ -5,7 +5,7 @@
5 bar &&
6 baz
7 done
8 ->) &&
8 +) &&
9 (
10 while true
11 do
@@ -13,7 +13,7 @@
13 bar &&
14 baz
15 done
16 ->) &&
16 +) &&
17 (
18 i=0 &&
19 while test $i -lt 10
@@ -21,4 +21,4 @@
21 echo $i || exit
22 i=$(($i + 1))
23 done
24 ->)
24 +)
t/chainlint/exit-subshell.expect
+1 -1
@@ -2,4 +2,4 @@
2 foo || exit 1
3 bar &&
4 baz
5 ->)
5 +)
t/chainlint/for-loop.expect
+1 -1
@@ -8,4 +8,4 @@
8 echo $i &&
9 cat $i
10 done
11 ->)
11 +)
t/chainlint/here-doc-close-subshell.expect
+1 -1
@@ -1,2 +1,2 @@
1 (
2 -> cat)
2 + cat)
t/chainlint/here-doc-multi-line-command-subst.expect
+2 -2
@@ -1,5 +1,5 @@
1 (
2 x=$(bobble &&
3 ->> wiffle) ?!AMP?!
3 + wiffle) ?!AMP?!
4 echo $x
5 ->)
5 +)
t/chainlint/here-doc-multi-line-string.expect
+1 -1
@@ -1,4 +1,4 @@
1 (
2 cat && echo "multi-line string" ?!AMP?!
3 bap
4 ->)
4 +)
t/chainlint/if-in-loop.expect
+1 -1
@@ -9,4 +9,4 @@
9 foo
10 done ?!AMP?!
11 bar
12 ->)
12 +)
t/chainlint/if-then-else.expect
+2 -2
@@ -11,10 +11,10 @@
11 cat
12 fi ?!AMP?!
13 echo poodle
14 ->) &&
14 +) &&
15 (
16 if test -n ""; then
17 echo very &&
18 echo empty
19 fi
20 ->)
20 +)
t/chainlint/incomplete-line.expect
+1 -1
@@ -1,4 +1,4 @@
1 line 1 line 2 line 3 line 4 &&
2 (
3 line 5 line 6 line 7 line 8
4 ->)
4 +)
t/chainlint/inline-comment.expect
+2 -2
@@ -2,8 +2,8 @@
2 foobar &&
3 barfoo ?!AMP?!
4 flibble "not a # comment"
5 ->) &&
5 +) &&
6
7 (
8 cd foo &&
9 -> flibble "not a # comment")
9 + flibble "not a # comment")
t/chainlint/loop-in-if.expect
+1 -1
@@ -9,4 +9,4 @@
9 foo
10 fi ?!AMP?!
11 bar
12 ->)
12 +)
t/chainlint/multi-line-nested-command-substitution.expect
+5 -5
@@ -3,16 +3,16 @@
3 x=$(
4 echo bar |
5 cat
6 ->> ) &&
6 + ) &&
7 echo ok
8 ->) |
8 +) |
9 sort &&
10 (
11 bar &&
12 x=$(echo bar |
13 cat
14 ->> ) &&
14 + ) &&
15 y=$(echo baz |
16 ->> fip) &&
16 + fip) &&
17 echo fail
18 ->)
18 +)
t/chainlint/multi-line-string.expect
+2 -2
@@ -2,8 +2,8 @@
2 x="line 1 line 2 line 3" &&
3 y="line 1 line2" ?!AMP?!
4 foobar
5 ->) &&
5 +) &&
6 (
7 echo "xyz" "abc def ghi" &&
8 barfoo
9 ->)
9 +)
t/chainlint/nested-cuddled-subshell.expect
+7 -7
@@ -1,19 +1,19 @@
1 (
2 (cd foo &&
3 bar
4 ->> ) &&
4 + ) &&
5 (cd foo &&
6 bar
7 ->> ) ?!AMP?!
7 + ) ?!AMP?!
8 (
9 cd foo &&
10 ->> bar) &&
10 + bar) &&
11 (
12 cd foo &&
13 ->> bar) ?!AMP?!
13 + bar) ?!AMP?!
14 (cd foo &&
15 ->> bar) &&
15 + bar) &&
16 (cd foo &&
17 ->> bar) ?!AMP?!
17 + bar) ?!AMP?!
18 foobar
19 ->)
19 +)
t/chainlint/nested-here-doc.expect
+1 -1
@@ -4,4 +4,4 @@ cat >foop &&
4 cat &&
5 cat ?!AMP?!
6 foobar
7 ->)
7 +)
t/chainlint/nested-subshell-comment.expect
+2 -2
@@ -6,6 +6,6 @@
6 # minor numbers of cows (or do they?)
7 baz &&
8 snaff
9 ->> ) ?!AMP?!
9 + ) ?!AMP?!
10 fuzzy
11 ->)
11 +)
t/chainlint/nested-subshell.expect
+3 -3
@@ -3,10 +3,10 @@
3 (
4 echo a &&
5 echo b
6 ->> ) >file &&
6 + ) >file &&
7 cd foo &&
8 (
9 echo a
10 echo b
11 ->> ) >file
12 ->)
11 + ) >file
12 +)
t/chainlint/p4-filespec.expect
+1 -1
@@ -1,4 +1,4 @@
1 (
2 p4 print -1 //depot/fiddle#42 >file &&
3 foobar
4 ->)
4 +)
t/chainlint/pipe.expect
+1 -1
@@ -5,4 +5,4 @@
5 fish |
6 cow ?!AMP?!
7 sunder
8 ->)
8 +)
t/chainlint/semicolon.expect
+5 -5
@@ -1,20 +1,20 @@
1 (
2 cat foo ; ?!AMP?! echo bar ?!AMP?!
3 cat foo ; ?!AMP?! echo bar
4 ->) &&
4 +) &&
5 (
6 cat foo ; ?!AMP?! echo bar &&
7 cat foo ; ?!AMP?! echo bar
8 ->) &&
8 +) &&
9 (
10 echo "foo; bar" &&
11 cat foo; ?!AMP?! echo bar
12 ->) &&
12 +) &&
13 (
14 foo;
15 ->) &&
15 +) &&
16 (
17 cd foo &&
18 for i in a b c; do
19 echo;
20 -> done)
20 + done)
t/chainlint/subshell-here-doc.expect
+2 -2
@@ -2,9 +2,9 @@
2 echo wobba gorgo snoot wafta snurb &&
3 cat >bip ?!AMP?!
4 echo >bop
5 ->) &&
5 +) &&
6 (
7 cat >bup &&
8 cat >bup3 &&
9 meep
10 ->)
10 +)
t/chainlint/subshell-one-liner.expect
+1 -1
@@ -11,4 +11,4 @@
11 (foo && bar) ?!AMP?!
12 (foo && bar; ?!AMP?! baz) ?!AMP?!
13 foobar
14 ->)
14 +)
t/chainlint/t7900-subtree.expect
+3 -3
@@ -1,10 +1,10 @@
1 (
2 chks="sub1sub2sub3sub4" &&
3 chks_sub=$(cat | sed "s,^,sub dir/,"
4 ->>) &&
4 +) &&
5 chkms="main-sub1main-sub2main-sub3main-sub4" &&
6 chkms_sub=$(cat | sed "s,^,sub dir/,"
7 ->>) &&
7 +) &&
8 subfiles=$(git ls-files) &&
9 check_equal "$subfiles" "$chkms$chks"
10 ->)
10 +)
t/chainlint/while-loop.expect
+1 -1
@@ -8,4 +8,4 @@
8 echo foo &&
9 cat bar
10 done
11 ->)
11 +)