Skip to content

fix(batch): export NODE_OPTIONS as a statement so compound shell comm…#933

Open
hakanbaysal wants to merge 1 commit into
mksglu:mainfrom
hakanbaysal:fix/shell-compound-nodeopts-925
Open

fix(batch): export NODE_OPTIONS as a statement so compound shell comm…#933
hakanbaysal wants to merge 1 commit into
mksglu:mainfrom
hakanbaysal:fix/shell-compound-nodeopts-925

Conversation

@hakanbaysal

Copy link
Copy Markdown

…ands work (#925)

The POSIX branch of buildBatchNodeOptionsPrefix emitted an inline NODE_OPTIONS='...' <command> assignment. That form is only valid before a simple command, so any batch command starting with a compound construct (if, for, while, a (...) subshell, or a { ...; } group) was rewritten into invalid shell and failed with syntax error near unexpected token. The failed run was then indexed, surfacing the syntax error instead of the intended output.

Emit a standalone export NODE_OPTIONS='...'; statement instead. This mirrors the PowerShell ($env:...; ) and cmd (set "..." && ) branches, which already use a separate statement, and composes with any following command. As a bonus the exported value now also reaches node invocations inside compound constructs (e.g. a for loop body), which the inline form could not do.

Updates the POSIX prefix test and adds real-compound-command coverage.

What / Why / How

Affected platforms

  • Claude Code
  • Cursor
  • VS Code Copilot (GitHub Copilot)
  • JetBrains Copilot
  • Gemini CLI
  • Qwen Code
  • OpenCode
  • KiloCode
  • Codex CLI
  • OpenClaw (Pi Agent)
  • Pi
  • Kiro
  • Antigravity
  • Zed
  • All platforms

Test plan

Checklist

  • Tests added/updated (TDD: red → green)
  • npm test passes
  • npm run typecheck passes
  • Docs updated if needed (README, platform-support.md)
  • No Windows path regressions (forward slashes only)
  • Targets next branch (unless hotfix)
Cross-platform notes

Our CI runs on Ubuntu, macOS, and Windows.

  • If touching file paths, verify forward-slash normalization on Windows
  • If touching hook paths, verify no backslash separators
  • Use path.join() / path.resolve(), never hardcode / separators
  • Use event-based stdin reading — readFileSync(0) breaks on Windows
  • Use os.tmpdir(), never hardcode /tmp

…ands work (mksglu#925)

The POSIX branch of buildBatchNodeOptionsPrefix emitted an inline
`NODE_OPTIONS='...' <command>` assignment. That form is only valid before a
*simple* command, so any batch command starting with a compound construct
(`if`, `for`, `while`, a `(...)` subshell, or a `{ ...; }` group) was rewritten
into invalid shell and failed with `syntax error near unexpected token`. The
failed run was then indexed, surfacing the syntax error instead of the intended
output.

Emit a standalone `export NODE_OPTIONS='...'; ` statement instead. This mirrors
the PowerShell (`$env:...; `) and cmd (`set "..." && `) branches, which already
use a separate statement, and composes with any following command. As a bonus
the exported value now also reaches `node` invocations *inside* compound
constructs (e.g. a `for` loop body), which the inline form could not do.

Updates the POSIX prefix test and adds real-compound-command coverage.
@bTimor

bTimor commented Jul 9, 2026

Copy link
Copy Markdown

Hey @hakanbaysal! 👋

This is a duplicate of #934 — same head branch, but targeting main directly. All fixes go through next first per our branching convention.

Closing in favour of #934. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants