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>
This commit is contained in:
Eric Sunshine 2021-12-13 01:30:54 -05:00 committed by Junio C Hamano
parent 0d7131763e
commit 5be30d0cd3
39 changed files with 80 additions and 89 deletions

View File

@ -76,12 +76,6 @@
# 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

View File

@ -2,8 +2,8 @@
foo &&
bar=$((42 + 1)) &&
baz
>) &&
) &&
(
bar=$((42 + 1)) ?!AMP?!
baz
>)
)

View File

@ -2,9 +2,9 @@
foo &&
bar=(gumbo stumbo wumbo) &&
baz
>) &&
) &&
(
foo &&
bar=${#bar[@]} &&
baz
>)
)

View File

@ -1,4 +1,4 @@
(
nothing &&
something
>)
)

View File

@ -9,4 +9,4 @@
echo c
} ?!AMP?!
baz
>)
)

View File

@ -3,4 +3,4 @@
bar ?!AMP?!
baz &&
wop
>)
)

View 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
>)
)

View File

@ -1,4 +1,4 @@
(
cd foo &&
(bar &&
>>> baz))
baz))

View 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
>)
)

View File

@ -2,8 +2,8 @@
foo &&
bar=$(gobble) &&
baz
>) &&
) &&
(
bar=$(gobble blocks) ?!AMP?!
baz
>)
)

View File

@ -1,4 +1,4 @@
(
nothing &&
something
>)
)

View File

@ -6,5 +6,5 @@ for i in a b c; do
else
echo >file
fi
> done) &&
done) &&
test ! -f file

View File

@ -3,5 +3,5 @@ if test -z ""; then
echo empty
else
echo bizzy
> fi) &&
fi) &&
echo foobar

View File

@ -1,5 +1,5 @@
(
while read x
do foobar bop || exit 1
> done <file ) &&
done <file ) &&
outside subshell

View 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)

View 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
>)
)

View File

@ -2,4 +2,4 @@
foo || exit 1
bar &&
baz
>)
)

View File

@ -8,4 +8,4 @@
echo $i &&
cat $i
done
>)
)

View File

@ -1,2 +1,2 @@
(
> cat)
cat)

View File

@ -1,5 +1,5 @@
(
x=$(bobble &&
>> wiffle) ?!AMP?!
wiffle) ?!AMP?!
echo $x
>)
)

View File

@ -1,4 +1,4 @@
(
cat && echo "multi-line string" ?!AMP?!
bap
>)
)

View File

@ -9,4 +9,4 @@
foo
done ?!AMP?!
bar
>)
)

View File

@ -11,10 +11,10 @@
cat
fi ?!AMP?!
echo poodle
>) &&
) &&
(
if test -n ""; then
echo very &&
echo empty
fi
>)
)

View File

@ -1,4 +1,4 @@
line 1 line 2 line 3 line 4 &&
(
line 5 line 6 line 7 line 8
>)
)

View File

@ -2,8 +2,8 @@
foobar &&
barfoo ?!AMP?!
flibble "not a # comment"
>) &&
) &&
(
cd foo &&
> flibble "not a # comment")
flibble "not a # comment")

View File

@ -9,4 +9,4 @@
foo
fi ?!AMP?!
bar
>)
)

View File

@ -3,16 +3,16 @@
x=$(
echo bar |
cat
>> ) &&
) &&
echo ok
>) |
) |
sort &&
(
bar &&
x=$(echo bar |
cat
>> ) &&
) &&
y=$(echo baz |
>> fip) &&
fip) &&
echo fail
>)
)

View File

@ -2,8 +2,8 @@
x="line 1 line 2 line 3" &&
y="line 1 line2" ?!AMP?!
foobar
>) &&
) &&
(
echo "xyz" "abc def ghi" &&
barfoo
>)
)

View 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
>)
)

View File

@ -4,4 +4,4 @@ cat >foop &&
cat &&
cat ?!AMP?!
foobar
>)
)

View File

@ -6,6 +6,6 @@
# minor numbers of cows (or do they?)
baz &&
snaff
>> ) ?!AMP?!
) ?!AMP?!
fuzzy
>)
)

View File

@ -3,10 +3,10 @@
(
echo a &&
echo b
>> ) >file &&
) >file &&
cd foo &&
(
echo a
echo b
>> ) >file
>)
) >file
)

View File

@ -1,4 +1,4 @@
(
p4 print -1 //depot/fiddle#42 >file &&
foobar
>)
)

View File

@ -5,4 +5,4 @@
fish |
cow ?!AMP?!
sunder
>)
)

View 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)

View File

@ -2,9 +2,9 @@
echo wobba gorgo snoot wafta snurb &&
cat >bip ?!AMP?!
echo >bop
>) &&
) &&
(
cat >bup &&
cat >bup3 &&
meep
>)
)

View File

@ -11,4 +11,4 @@
(foo && bar) ?!AMP?!
(foo && bar; ?!AMP?! baz) ?!AMP?!
foobar
>)
)

View 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"
>)
)

View File

@ -8,4 +8,4 @@
echo foo &&
cat bar
done
>)
)