]> git.ipfire.org Git - thirdparty/git.git/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 f5fcca09ca5d55f2b2edfc9ef1b58d317c7c4d39..2689e13636f7036a90b0ad9c03d979c428b30588 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 56cd5b69f5b498328909e5b696b14bdf5e8a7f5a..46ee1046af73582ea5adf5e91b0be62025684bb6 100644 (file)
@@ -2,8 +2,8 @@
        foo &&
        bar=$((42 + 1)) &&
        baz
->) &&
+) &&
 (
        bar=$((42 + 1)) ?!AMP?!
        baz
->)
+)
index c4a830d1c1d6df9ae72c1d5c7777ceb056383388..4c34eaee45e2f706e80560edfa271f4a5e245a9e 100644 (file)
@@ -2,9 +2,9 @@
        foo &&
        bar=(gumbo stumbo wumbo) &&
        baz
->) &&
+) &&
 (
        foo &&
        bar=${#bar[@]} &&
        baz
->)
+)
index 3be939ed388c3668f030f78034a8c0204ee55dd2..f76fde1ffba91d7becf17c0990c39ac25a7083f0 100644 (file)
@@ -1,4 +1,4 @@
 (
        nothing &&
        something
->)
+)
index 6333237cb2fdb87110da7be204a3cad86b8541ff..da60257ebc4e1d2e019e2b8fee8da3742849ddd7 100644 (file)
@@ -9,4 +9,4 @@
                echo c
        } ?!AMP?!
        baz
->)
+)
index 0960a8c7c0d9bcce977491c2056242fcdd6477a2..cfb58fb6b937be645f79167eae7fa27ec27d9618 100644 (file)
@@ -3,4 +3,4 @@
        bar ?!AMP?!
        baz &&
        wop
->)
+)
index a4b92d46131c2953546e1744e143276a36b70202..31f280d8ceb3152a057c26cabe926f9defb8bdac 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 2a910f9d66604cd2f4a95377a9071a247e1e6d6e..5ef509eb4987593e56027e8f8bb0171d75ab23d8 100644 (file)
@@ -1,4 +1,4 @@
 (
 cd foo &&
        (bar &&
->>>            baz))
+               baz))
index 184688718a9c030097cab0bea570c829189ef34b..0f87db9ae6891f8536c6eec73b71e5f049ca9667 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 f276067b7b3f299e1244a80c2d9ef7f352afccf7..c72e4df9e709d1e26f393d6e2d906626d94aa3a3 100644 (file)
@@ -2,8 +2,8 @@
        foo &&
        bar=$(gobble) &&
        baz
->) &&
+) &&
 (
        bar=$(gobble blocks) ?!AMP?!
        baz
->)
+)
index 3be939ed388c3668f030f78034a8c0204ee55dd2..f76fde1ffba91d7becf17c0990c39ac25a7083f0 100644 (file)
@@ -1,4 +1,4 @@
 (
        nothing &&
        something
->)
+)
index 9674b88cf252f7409241c847d6219547ff2b07cc..b8aa626ed0e7f2dc63cfa5d9450ac986b7d74a67 100644 (file)
@@ -6,5 +6,5 @@ for i in a b c; do
    else
      echo >file
    fi
-> done) &&
+ done) &&
 test ! -f file
index ab2a026fbc2f68048d67174fad32134ded3d2ce7..4e089b087a867566054120b67e663c73cc58f6aa 100644 (file)
@@ -3,5 +3,5 @@ if test -z ""; then
     echo empty
  else
     echo bizzy
-> fi) &&
+ fi) &&
 echo foobar
index 8c0260d7f1d9ce7e85a8b0d47ffe97f57f39b92e..7932303763285828a78fb11465946bee8a477508 100644 (file)
@@ -1,5 +1,5 @@
 (
  while read x
   do foobar bop || exit 1
->  done <file ) &&
+  done <file ) &&
 outside subshell
index b6c4ed90a97a45806ce2b23b27e2e23b0c319369..773476adc85138d9bdbf584bcb0d0a12573b033e 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 84d8bdebc02660d3a4ad0aeb341a9f991547b46c..f76aa60466adaf394b2e368e5feb3b54e23b30f8 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 bf78454f74c83d27b059b504859213abdb9acc6c..da80339f781230c19bc7203603d6310454dba4a9 100644 (file)
@@ -2,4 +2,4 @@
        foo || exit 1
        bar &&
        baz
->)
+)
index dc209e21bdc73eeea2bae256852493a6b05c01c2..b74df064c5053c5c87d6f3021fdfa394b6037fdd 100644 (file)
@@ -8,4 +8,4 @@
                echo $i &&
                cat $i
        done
->)
+)
index f011e335e5f12c36460836635dd220153de8f9e1..e7485265709ae942a39f70fa2b95e4d433c3bda7 100644 (file)
@@ -1,2 +1,2 @@
 (
->      cat)
+       cat)
index 3a35bb014cc29019d1fdfd04310084e3e144574c..f1248f8aded77aff41bafd67ec348c09324960a4 100644 (file)
@@ -1,5 +1,5 @@
 (
        x=$(bobble &&
->>             wiffle) ?!AMP?!
+               wiffle) ?!AMP?!
        echo $x
->)
+)
index a3b9a5472df07f7c439ab33419f64b5b06d993ec..7e883b252e11f2092d0b31d8b8d919d302a0ba8f 100644 (file)
@@ -1,4 +1,4 @@
 (
        cat && echo "multi-line string" ?!AMP?!
        bap
->)
+)
index 7d918372695a7f4d4c45280bc7aa657f012adfdd..03b82a3e58c21e1300befb317f19c7f063fba3ec 100644 (file)
@@ -9,4 +9,4 @@
                foo
        done ?!AMP?!
        bar
->)
+)
index 3055d5606c59298055ffa956a82c83a584064949..debcf7b75618cd23775df37c2e9d3f8247d4299f 100644 (file)
                cat
        fi ?!AMP?!
        echo poodle
->) &&
+) &&
 (
        if test -n ""; then
                echo very &&
                echo empty
        fi
->)
+)
index 2f3ebabdc286f440dec9bc0df2596e2fa7ff17ee..ffac8f901857eef401cdcfa6d60734c92a96b416 100644 (file)
@@ -1,4 +1,4 @@
 line 1 line 2 line 3 line 4 &&
 (
        line 5  line 6  line 7  line 8
->)
+)
index 3d655a32b0b269879a239fec61c3b3ad061b558d..f6b42757d235d32420b57e8380d590b029dde89b 100644 (file)
@@ -2,8 +2,8 @@
        foobar &&
        barfoo ?!AMP?!
        flibble "not a # comment"
->) &&
+) &&
 
 (
 cd foo &&
->      flibble "not a # comment")
+       flibble "not a # comment")
index cebd3ae95e38c048fb44819e5ae334fc2081259f..e1be42376c5ef480c791222dc0cc75d4d01fe1ce 100644 (file)
@@ -9,4 +9,4 @@
                foo
        fi ?!AMP?!
        bar
->)
+)
index 59b6c8b850a16d087e5d322c8ee25dcbeb553fa5..300058341b6f303dce9d8e8105b6f16fa25f2ebf 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 f1be2baf0af154a79f529c1e84e3b7d78a49ecc3..ab0dadf748e859968e654cf8d6a28a3a5882460b 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 aa522658edff1c45476cb7fe44d15c2064fbfd5c..2a86885ee6a330450a76591248b60b89e601816f 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 f9604d3facad8c6f3883e671e36a6be2723d7f93..2a51205d3294d421b9a351474dff04a025f0b421 100644 (file)
@@ -4,4 +4,4 @@ cat >foop &&
        cat &&
        cat ?!AMP?!
        foobar
->)
+)
index 925e49bae9586bbcf0c791599c6c0ed2fece56cf..9138cf386d359267143945d13c1882b0feb5c6f4 100644 (file)
@@ -6,6 +6,6 @@
                # minor numbers of cows (or do they?)
                baz &&
                snaff
->>     ) ?!AMP?!
+       ) ?!AMP?!
        fuzzy
->)
+)
index c8165ad19ec5da791ac15fe5800d374885057633..41a48adaa2b8ff62784f9fe022281e094063e96a 100644 (file)
@@ -3,10 +3,10 @@
        (
                echo a &&
                echo b
->>     ) >file &&
+       ) >file &&
        cd foo &&
        (
                echo a
                echo b
->>     ) >file
->)
+       ) >file
+)
index 98b3d881fda9a8d488fe6bbd5ffe7cdf263fb60a..1290fd1ff27153f8b2daabb1e5fdec711b530ab2 100644 (file)
@@ -1,4 +1,4 @@
 (
        p4 print -1 //depot/fiddle#42 >file &&
        foobar
->)
+)
index ede6bcc6078e39f202a8205bc0b3777de59c58f4..2cfc0282970db02dd37eaf1c0c079e22a233cef1 100644 (file)
@@ -5,4 +5,4 @@
        fish |
        cow ?!AMP?!
        sunder
->)
+)
index 54a08ce582f1a2391c813edbcdc4e8e7f580011f..05141a96cf3876cf5c6c7689c30cf9387e3d3d3b 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 9d3f25b3f57094a3f50264982f726d29caec8073..b7250ca753d3500291b08c537bee8091104475e4 100644 (file)
@@ -2,9 +2,9 @@
        echo wobba             gorgo snoot             wafta snurb &&
        cat >bip ?!AMP?!
        echo >bop
->) &&
+) &&
 (
        cat >bup &&
        cat >bup3 &&
        meep
->)
+)
index 4b44632b099635ed44014c9727b0b0b0047b663e..b7015361bfe6a3555d02e97d2bdc0413b8f8c432 100644 (file)
@@ -11,4 +11,4 @@
        (foo && bar) ?!AMP?!
        (foo && bar; ?!AMP?! baz) ?!AMP?!
        foobar
->)
+)
index f769244ef6426ac2dc459465f4dd520cbfb00bd6..215aca01c2c1b2baa82d55f12928345138ed50dd 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 f8b9fcf62b568a7c26ff49ad53db1e0a35e65ea4..e2813b378e8165e72ed9dfa4777154219e24c627 100644 (file)
@@ -8,4 +8,4 @@
                echo foo &&
                cat bar
        done
->)
+)