Apply macro expansion to teardown commands and fix @def continuation parsing

Teardown commands were missing the expandMacro call that setup and
parsed commands already received. Also relax the continuation-line
guard to catch bare `$` (not just `$ `) so lines like `$VAR` are
not silently consumed as continuation text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Wanstrath 2026-03-19 11:59:08 -07:00
parent f508e30fcb
commit 7231c07a8b
2 changed files with 2 additions and 2 deletions

View File

@ -150,7 +150,7 @@ program
commands: [ commands: [
...setupCommands.map(expandMacro), ...setupCommands.map(expandMacro),
...parsed.commands.map(expandMacro), ...parsed.commands.map(expandMacro),
...teardownCommands, ...teardownCommands.map(expandMacro),
], ],
} }

View File

@ -82,7 +82,7 @@ function parseDefDirective(
while (body.endsWith("\\") && i + extra + 1 < rawLines.length) { while (body.endsWith("\\") && i + extra + 1 < rawLines.length) {
const next = rawLines[i + extra + 1]! const next = rawLines[i + extra + 1]!
if (next.startsWith("$ ") || next.startsWith("@")) { if (next.startsWith("$") || next.startsWith("@")) {
throw new Error(`${path}:${i + extra + 2}: @def continuation consumed a command or directive line`) throw new Error(`${path}:${i + extra + 2}: @def continuation consumed a command or directive line`)
} }
body = body.slice(0, -1).trimEnd() + "\n" + next.trim() body = body.slice(0, -1).trimEnd() + "\n" + next.trim()