# 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
x
bnstslrp
:nstcl
-s/^/>>/
# is it "))" which closes nested and parent subshells?
/)[ ]*)/bslurp
bchkchn
s/\( ?!AMP?!\)* ?!AMP?!$//
p
x
-s/^/>/
b
# found closing "...)" -- exit subshell loop
x
p
x
-s/^/>/
b
(
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)
(
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"
->)
+)