Stderr Redirection Causing Unexpected Behavior in Command Execution

Resolved 💬 3 comments Opened Jul 30, 2025 by mattgodbolt Closed Jan 4, 2026

Bug Description
Another instance where 2>&1 caused issues.

For context claude was trying to run webpack and then the 2 confused it:

● Bash(npm run webpack 2>&1 | head -10)
  ⎿  > compiler-explorer@0.0.3 webpack                                                                                                                 
     > node --no-warnings=ExperimentalWarning --import=tsx ./node_modules/webpack-cli/bin/cli.js --node-env=production --config webpack.config.esm.ts 2
     … +18 lines (ctrl+r to expand)

● That's a weird error. Let me try a simpler test:

● Bash(npm run ts-check)
  ⎿  > compiler-explorer@0.0.3 ts-check
     > npm-run-all ts-check:*
     … +15 lines (ctrl+r to expand)

● Good, TypeScript is fine. Let me try the webpack command without the weird "2" at the end:

● Bash(npm run webpack)
  ⎿  No (tell Claude what to do differently)

> /bug 
  ⎿  Bug report submitted

Environment Info

  • Platform: linux
  • Terminal: gnome-terminal
  • Version: 1.0.63
  • Feedback ID: c12d30df-e48a-4581-b669-b0e0867779e3

Errors

[{"error":"SyntaxError: JSON Parse error: Unable to parse JSON string\n    at <parse> (:0)\n    at parse (unknown)\n    at <anonymous> (/$bunfs/root/claude:581:9928)\n    at W (/$bunfs/root/claude:456:14413)\n    at evG (/$bunfs/root/claude:1334:10268)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-07-30T19:15:13.696Z"},{"error":"Error: Request was aborted.\n    at new nW (unknown:1:28)\n    at new BY (/$bunfs/root/claude:1171:12033)\n    at new kJ (/$bunfs/root/claude:1171:12821)\n    at _createMessage (/$bunfs/root/claude:1179:7955)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-07-30T19:23:42.001Z"}]

Probably linked to #4711

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗