fix(node): pass paths to child processes as arguments, not shell strings - #268
Merged
Merged
Conversation
`agent init --with-gemini` built `gemini skills link "<path>"` as a shell string, quoting the path with JSON.stringify. Double quotes do not stop a POSIX shell from expanding $(...) or backticks, and the path comes from the working directory. Run gemini with an argument array instead; Windows keeps cmd.exe, which it needs for gemini's .cmd shim and which treats a double-quoted path literally. Same change for two siblings rooted in the home directory: the global `git config core.hooksPath` call in install-hook and the local betterleaks version probe in status. Adds an end-to-end test that runs init from a directory whose name contains shell syntax, with a stub gemini on PATH, and asserts the path arrives literally and nothing is executed.
This was referenced Oct 2, 2026
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.
Summary
rafter agent init --with-geminiregistered skills by runninggemini skills link "<path>"as a shell string, with the path quoted byJSON.stringify.Double quotes do not stop a POSIX shell from expanding
$(...)or backticks, and with--localthe path is under the working directory.init.ts: rungeminiwith an argument array (execFileSync). On Windows the call keepscmd.exe, which it needs to run gemini's.cmdshim and which treats a double-quoted path literally.install-hook.ts: the globalgit config core.hooksPathcall uses an argument array.status.ts: the local betterleaksversionprobe uses an argument array.The last two are rooted in the home directory; they change for consistency.
The Python CLI already passes these as argument lists and is unaffected.
Test
node/tests/agent-init-gemini-link.test.tsruns the built CLI'sagent init --local --with-geminifrom a temporary directory whose name contains shell syntax, with a stubgeminionPATHthat logs its arguments.It asserts the skill path reaches gemini as one literal argument and that the embedded command did not run.
It fails on
mainand passes on this branch (skipped on Windows).tscclean. Node suite: 2275 passed; the 3 Cursor hook tests that fail also fail onmainin a local checkout and are unrelated.