]> Kevux Git Server - rit/commitdiff
chainlint.sed: drop subshell-closing ">" annotation
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 13 Dec 2021 06:30:54 +0000 (01:30 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Dec 2021 22:15:29 +0000 (14:15 -0800)
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>
39 files changed:
t/chainlint.sed
t/chainlint/arithmetic-expansion.expect
t/chainlint/bash-array.expect
t/chainlint/blank-line.expect
t/chainlint/block.expect
t/chainlint/broken-chain.expect
t/chainlint/case.expect
t/chainlint/close-nested-and-parent-together.expect
t/chainlint/close-subshell.expect
t/chainlint/command-substitution.expect
t/chainlint/comment.expect
t/chainlint/complex-if-in-cuddled-loop.expect
t/chainlint/cuddled-if-then-else.expect
t/chainlint/cuddled-loop.expect
t/chainlint/cuddled.expect
t/chainlint/exit-loop.expect
t/chainlint/exit-subshell.expect
t/chainlint/for-loop.expect
t/chainlint/here-doc-close-subshell.expect
t/chainlint/here-doc-multi-line-command-subst.expect
t/chainlint/here-doc-multi-line-string.expect
t/chainlint/if-in-loop.expect
t/chainlint/if-then-else.expect
t/chainlint/incomplete-line.expect
t/chainlint/inline-comment.expect
t/chainlint/loop-in-if.expect
t/chainlint/multi-line-nested-command-substitution.expect
t/chainlint/multi-line-string.expect
t/chainlint/nested-cuddled-subshell.expect
t/chainlint/nested-here-doc.expect
t/chainlint/nested-subshell-comment.expect
t/chainlint/nested-subshell.expect
t/chainlint/p4-filespec.expect
t/chainlint/pipe.expect
t/chainlint/semicolon.expect
t/chainlint/subshell-here-doc.expect
t/chainlint/subshell-one-liner.expect
t/chainlint/t7900-subtree.expect
t/chainlint/while-loop.expect

index f5fcca0..2689e13 100644 (file)
 # newline, thus the closing here-doc tag has been found. The closing tag line
 # and the "<...>" prefix on the target line are then discarded, leaving just
 # the target line "cat >out".
-#
-# To facilitate regression testing (and manual debugging), a ">" annotation is
-# applied to the line containing ")" which closes a subshell, ">>" to a line
-# closing a nested subshell, and ">>>" to a line closing both at once. This
-# makes it easy to detect whether the heuristics correctly identify
-# end-of-subshell.
 #------------------------------------------------------------------------------
 
 # incomplete line -- slurp up next line
@@ -337,7 +331,6 @@ n
 x
 bnstslrp
 :nstcl
-s/^/>>/
 # is it "))" which closes nested and parent subshells?
 /)[    ]*)/bslurp
 bchkchn
@@ -357,7 +350,6 @@ x
 s/\( ?!AMP?!\)* ?!AMP?!$//
 p
 x
-s/^/>/
 b
 
 # found closing "...)" -- exit subshell loop
@@ -365,5 +357,4 @@ b
 x
 p
 x
-s/^/>/
 b
index 56cd5b6..46ee104 100644 (file)
@@ -2,8 +2,8 @@
        foo &&
        bar=$((42 + 1)) &&
        baz
->) &&
+) &&
 (
        bar=$((42 + 1)) ?!AMP?!
        baz
->)
+)
index c4a830d..4c34eae 100644 (file)
@@ -2,9 +2,9 @@
        foo &&
        bar=(gumbo stumbo wumbo) &&
        baz
->) &&
+) &&
 (
        foo &&
        bar=${#bar[@]} &&
        baz
->)
+)
index 3be939e..f76fde1 100644 (file)
@@ -1,4 +1,4 @@
 (
        nothing &&
        something
->)
+)
index 6333237..da60257 100644 (file)
@@ -9,4 +9,4 @@
                echo c
        } ?!AMP?!
        baz
->)
+)
index 0960a8c..cfb58fb 100644 (file)
@@ -3,4 +3,4 @@
        bar ?!AMP?!
        baz &&
        wop
->)
+)
index a4b92d4..31f280d 100644 (file)
@@ -4,16 +4,16 @@
        *) bar ;;
        esac &&
        foobar
->) &&
+) &&
 (
        case "$x" in
        x) foo ;;
        *) bar ;;
        esac ?!AMP?!
        foobar
->) &&
+) &&
 (
        case "$x" in 1) true;; esac &&
        case "$y" in 2) false;; esac ?!AMP?!
        foobar
->)
+)
index 2a910f9..5ef509e 100644 (file)
@@ -1,4 +1,4 @@
 (
 cd foo &&
        (bar &&
->>>            baz))
+               baz))
index 1846887..0f87db9 100644 (file)
@@ -1,25 +1,25 @@
 (
        foo
->) &&
+) &&
 (
        bar
->) >out &&
+) >out &&
 (
        baz
->) 2>err &&
+) 2>err &&
 (
        boo
->) <input &&
+) <input &&
 (
        bip
->) | wuzzle &&
+) | wuzzle &&
 (
        bop
->) | fazz      fozz &&
+) | fazz       fozz &&
 (
        bup
->) |
+) |
 fuzzle &&
 (
        yop
->)
+)
index f276067..c72e4df 100644 (file)
@@ -2,8 +2,8 @@
        foo &&
        bar=$(gobble) &&
        baz
->) &&
+) &&
 (
        bar=$(gobble blocks) ?!AMP?!
        baz
->)
+)
index 3be939e..f76fde1 100644 (file)
@@ -1,4 +1,4 @@
 (
        nothing &&
        something
->)
+)
index 9674b88..b8aa626 100644 (file)
@@ -6,5 +6,5 @@ for i in a b c; do
    else
      echo >file
    fi
-> done) &&
+ done) &&
 test ! -f file
index ab2a026..4e089b0 100644 (file)
@@ -3,5 +3,5 @@ if test -z ""; then
     echo empty
  else
     echo bizzy
-> fi) &&
+ fi) &&
 echo foobar
index 8c0260d..7932303 100644 (file)
@@ -1,5 +1,5 @@
 (
  while read x
   do foobar bop || exit 1
->  done <file ) &&
+  done <file ) &&
 outside subshell
index b6c4ed9..773476a 100644 (file)
@@ -1,21 +1,21 @@
 (
 cd foo &&
        bar
->) &&
+) &&
 
 (
 cd foo ?!AMP?!
        bar
->) &&
+) &&
 
 (
        cd foo &&
->      bar) &&
+       bar) &&
 
 (
 cd foo &&
->      bar) &&
+       bar) &&
 
 (
 cd foo ?!AMP?!
->      bar)
+       bar)
index 84d8bde..f76aa60 100644 (file)
@@ -5,7 +5,7 @@
                bar &&
                baz
        done
->) &&
+) &&
 (
        while true
        do
@@ -13,7 +13,7 @@
                bar &&
                baz
        done
->) &&
+) &&
 (
        i=0 &&
        while test $i -lt 10
@@ -21,4 +21,4 @@
                echo $i || exit
                i=$(($i + 1))
        done
->)
+)
index bf78454..da80339 100644 (file)
@@ -2,4 +2,4 @@
        foo || exit 1
        bar &&
        baz
->)
+)
index dc209e2..b74df06 100644 (file)
@@ -8,4 +8,4 @@
                echo $i &&
                cat $i
        done
->)
+)
index 3a35bb0..f1248f8 100644 (file)
@@ -1,5 +1,5 @@
 (
        x=$(bobble &&
->>             wiffle) ?!AMP?!
+               wiffle) ?!AMP?!
        echo $x
->)
+)
index a3b9a54..7e883b2 100644 (file)
@@ -1,4 +1,4 @@
 (
        cat && echo "multi-line string" ?!AMP?!
        bap
->)
+)
index 7d91837..03b82a3 100644 (file)
@@ -9,4 +9,4 @@
                foo
        done ?!AMP?!
        bar
->)
+)
index 3055d56..debcf7b 100644 (file)
                cat
        fi ?!AMP?!
        echo poodle
->) &&
+) &&
 (
        if test -n ""; then
                echo very &&
                echo empty
        fi
->)
+)
index 2f3ebab..ffac8f9 100644 (file)
@@ -1,4 +1,4 @@
 line 1 line 2 line 3 line 4 &&
 (
        line 5  line 6  line 7  line 8
->)
+)
index 3d655a3..f6b4275 100644 (file)
@@ -2,8 +2,8 @@
        foobar &&
        barfoo ?!AMP?!
        flibble "not a # comment"
->) &&
+) &&
 
 (
 cd foo &&
->      flibble "not a # comment")
+       flibble "not a # comment")
index cebd3ae..e1be423 100644 (file)
@@ -9,4 +9,4 @@
                foo
        fi ?!AMP?!
        bar
->)
+)
index 59b6c8b..3000583 100644 (file)
@@ -3,16 +3,16 @@
        x=$(
                echo bar |
                cat
->>     ) &&
+       ) &&
        echo ok
->) |
+) |
 sort &&
 (
        bar &&
        x=$(echo bar |
                cat
->>     ) &&
+       ) &&
        y=$(echo baz |
->>             fip) &&
+               fip) &&
        echo fail
->)
+)
index f1be2ba..ab0dadf 100644 (file)
@@ -2,8 +2,8 @@
        x="line 1               line 2          line 3" &&
        y="line 1               line2" ?!AMP?!
        foobar
->) &&
+) &&
 (
        echo "xyz" "abc         def             ghi" &&
        barfoo
->)
+)
index aa52265..2a86885 100644 (file)
@@ -1,19 +1,19 @@
 (
        (cd foo &&
                bar
->>     ) &&
+       ) &&
        (cd foo &&
                bar
->>     ) ?!AMP?!
+       ) ?!AMP?!
        (
                cd foo &&
->>             bar) &&
+               bar) &&
        (
                cd foo &&
->>             bar) ?!AMP?!
+               bar) ?!AMP?!
        (cd foo &&
->>             bar) &&
+               bar) &&
        (cd foo &&
->>             bar) ?!AMP?!
+               bar) ?!AMP?!
        foobar
->)
+)
index f9604d3..2a51205 100644 (file)
@@ -4,4 +4,4 @@ cat >foop &&
        cat &&
        cat ?!AMP?!
        foobar
->)
+)
index 925e49b..9138cf3 100644 (file)
@@ -6,6 +6,6 @@
                # minor numbers of cows (or do they?)
                baz &&
                snaff
->>     ) ?!AMP?!
+       ) ?!AMP?!
        fuzzy
->)
+)
index c8165ad..41a48ad 100644 (file)
@@ -3,10 +3,10 @@
        (
                echo a &&
                echo b
->>     ) >file &&
+       ) >file &&
        cd foo &&
        (
                echo a
                echo b
->>     ) >file
->)
+       ) >file
+)
index 98b3d88..1290fd1 100644 (file)
@@ -1,4 +1,4 @@
 (
        p4 print -1 //depot/fiddle#42 >file &&
        foobar
->)
+)
index ede6bcc..2cfc028 100644 (file)
@@ -5,4 +5,4 @@
        fish |
        cow ?!AMP?!
        sunder
->)
+)
index 54a08ce..05141a9 100644 (file)
@@ -1,20 +1,20 @@
 (
        cat foo ; ?!AMP?! echo bar ?!AMP?!
        cat foo ; ?!AMP?! echo bar
->) &&
+) &&
 (
        cat foo ; ?!AMP?! echo bar &&
        cat foo ; ?!AMP?! echo bar
->) &&
+) &&
 (
        echo "foo; bar" &&
        cat foo; ?!AMP?! echo bar
->) &&
+) &&
 (
        foo;
->) &&
+) &&
 (
 cd foo &&
        for i in a b c; do
                echo;
->      done)
+       done)
index 9d3f25b..b7250ca 100644 (file)
@@ -2,9 +2,9 @@
        echo wobba             gorgo snoot             wafta snurb &&
        cat >bip ?!AMP?!
        echo >bop
->) &&
+) &&
 (
        cat >bup &&
        cat >bup3 &&
        meep
->)
+)
index 4b44632..b701536 100644 (file)
@@ -11,4 +11,4 @@
        (foo && bar) ?!AMP?!
        (foo && bar; ?!AMP?! baz) ?!AMP?!
        foobar
->)
+)
index f769244..215aca0 100644 (file)
@@ -1,10 +1,10 @@
 (
        chks="sub1sub2sub3sub4" &&
        chks_sub=$(cat | sed "s,^,sub dir/,"
->>) &&
+) &&
        chkms="main-sub1main-sub2main-sub3main-sub4" &&
        chkms_sub=$(cat | sed "s,^,sub dir/,"
->>) &&
+) &&
        subfiles=$(git ls-files) &&
        check_equal "$subfiles" "$chkms$chks"
->)
+)
index f8b9fcf..e2813b3 100644 (file)
@@ -8,4 +8,4 @@
                echo foo &&
                cat bar
        done
->)
+)