fix(terminal): quote the sh -c payload so resume survives spaces in paths#406
Merged
Conversation
…aths The `open --args` runners (Ghostty/kitty/Alacritty/WezTerm) wrapped the `sh -c` payload in raw single quotes, but withCwd already single-quotes the cwd and the resume command single-quotes the session id. The nested quotes cancel out under the outer shell, so it works only when nothing contains a space — a cwd like "/Users/x/My Project" splits into "cd /Users/x/My" plus stray args, the resume command is dropped, and the window opens in the wrong directory. Extract keepAliveArg(), which shell-quotes the whole "<cmd>; exec $SHELL" payload as one token, and route all four runners through it. Adds regression tests that tokenize each emitted command with a real /bin/sh and assert the payload survives as a single argument for spaced paths and embedded quotes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
graydawnc
force-pushed
the
fix/terminal-resume-quoting
branch
from
July 7, 2026 08:37
039957e to
e996fcf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes shell-quoting in the
open --argsterminal runners (Ghostty / kitty / Alacritty / WezTerm) so the resume command survives cwds and commands that contain spaces or single quotes.Depends on #405 (stacked — this branch bases on
feat/terminal-ghostty). Merge #405 first.Why
Each runner wrapped the
sh -cpayload in raw single quotes:But
withCwdalready single-quotes the cwd (cd '<cwd>' && …) and the resume command single-quotes the session id. The nested single quotes cancel out under the outer shell, so it only works when nothing contains a space. A common macOS project path like/Users/x/My Projecttokenizes into:so
sh -c cdjust cd's to$HOMEand exits — the resume command is dropped and the window opens in the wrong directory (and never runsexec $SHELL).How it connects
keepAliveArg(cmd, cwd), which shell-quotes the entire"<cmd>; exec $SHELL"payload as one token, and routes all fouropen --argsrunners through it. This also removes the fourth byte-for-byte copy of the runner template.Test plan
/bin/shand assert the payload survives as a single argument, for both a spaced cwd (/tmp/My Proj) and an embedded single quote. These fail on the pre-fix runners (the spaced path splits into two argv tokens) and pass after.