fix(shell): parse arguments in defaultShell so flagged shells don't hang - #577
fix(shell): parse arguments in defaultShell so flagged shells don't hang#577JosephDoUrden wants to merge 1 commit into
Conversation
getShellSpawnArgs treated the whole defaultShell value as a single executable path, so a value like "pwsh.exe -NoProfile -NoLogo" or "/bin/bash --norc" tried to spawn a non-existent binary and hung until the client timeout. Split the value into executable and args (quote-aware), match the shell on the executable name only, and keep the caller's args ahead of the standard flags. Single-token values are unchanged. Fixes wonderwhy-er#448
📝 WalkthroughWalkthrough
ChangesShell argument support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Config
participant TerminalManager
participant ShellProcess
Config->>TerminalManager: Provide shell path with optional arguments
TerminalManager->>TerminalManager: Split executable and arguments
TerminalManager->>ShellProcess: Spawn with preserved arguments and command flags
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/test-default-shell-args.js (1)
17-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGood test coverage for the primary use cases.
The tests correctly validate single-token non-regression, pwsh with flags, bash with flags, quoted executable paths with spaces, and cmd.exe verbatim handling. Consider adding a test for the unknown-shell fallback to verify that
shellArgsare dropped anduseShellOptionis set to the extracted executable — this is the one code path ingetShellSpawnArgsnot covered by the current suite.🧪 Suggested test for the unknown-shell fallback
console.log('✓ cmd.exe /q splits correctly and stays verbatim'); + // 6. Unknown shell with args: executable extracted, args dropped, useShellOption set + cfg = getShellSpawnArgs('myshell --norc', 'echo hi'); + assert.strictEqual(cfg.executable, 'echo hi'); + assert.deepStrictEqual(cfg.args, []); + assert.strictEqual(cfg.useShellOption, 'myshell'); + console.log('✓ unknown shell fallback extracts executable and drops args'); + console.log('\n✅ All defaultShell argument-parsing tests passed');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/test-default-shell-args.js` around lines 17 - 55, Add coverage in runDefaultShellArgsTests for an unrecognized shell passed with flags, using getShellSpawnArgs. Assert that shellArgs are omitted and useShellOption is set to the extracted executable, preserving the expected fallback behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/test-default-shell-args.js`:
- Around line 17-55: Add coverage in runDefaultShellArgsTests for an
unrecognized shell passed with flags, using getShellSpawnArgs. Assert that
shellArgs are omitted and useShellOption is set to the extracted executable,
preserving the expected fallback behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9909f5e4-c66c-4917-859b-21f3f29f84e7
📒 Files selected for processing (3)
src/config-field-definitions.tssrc/terminal-manager.tstest/test-default-shell-args.js
|
Please someone take a look at this, it solves the issue quite nicely. You can get around a little right now with a shim, but that still is slower than native noProfile. |
Fixes #448.
getShellSpawnArgstreated the wholedefaultShellvalue as one executable path, so a value likepwsh.exe -NoProfile -NoLogoor/bin/bash --norctried to spawn a binary named after the entire string, hit ENOENT and the call just hung until the client timeout. Now the value is split into executable + args (quote-aware, so an executable path with spaces still survives), matched on the executable name, and the extra args are kept ahead of the usual login/-c flags. Single-token values behave exactly as before.Added test/test-default-shell-args.js covering the split, the existing test-default-shell.js still passes, and I checked a multi-token shell actually runs a command end to end on macOS.