+89
−1
+6
−0
Loading
runCaptured()'s forked child recursed into parse() while still sharing
whatever _heredocSource the parent had (the real script file, or a real
terminal) -- parse()'s own needsMoreInput() pull-loop could then read
from it looking for "more input" that a command-substitution's already-
complete, already-parenthesized text never legitimately needs. Found via
a real hang: the kernel's own scripts/syscallhdr.sh has
"guard=_UAPI_ASM_$(basename "$outfile" |\n\tsed ... \\\n\t-e ...)", and
evaluating it wedged the whole build reading from /dev/pts forever.
Nulling _heredocSource in the child fixes it.
That then exposed two more real bugs in the same area, both needed for
this exact substitution to produce the right guard string instead of a
truncated "_UAPI_ASM_":
- needsMoreInput() never recognized a bare trailing '|'/'&&' (a pipeline
split across lines with no backslash) as incomplete, so "cmd1 |" and
"cmd2" on the next line ran as two unrelated statements.
- the join for that case must use a space, not '\n' -- unlike every other
needsMoreInput() reason (heredoc/if/while/case bodies), where the
newline must survive as a real statement separator, here the two lines
are the SAME command; joining with '\n' fed the per-statement splitter
a false statement boundary right back.
Co-Authored-By:
Claude Sonnet 5 <noreply@anthropic.com>