Repository navigation
fix: separate PosixShellType.Sh case with POSIX-safe single-quote escaping - #334988
Open
Viraj Mishra (VirajMishra1) wants to merge 2 commits into
Open
Viraj Mishra (VirajMishra1) wants to merge 2 commits into
Viraj Mishra (VirajMishra1) wants to merge 2 commits into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical test expectation failures and missing quote-combination coverage must be addressed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Separates POSIX sh escaping and tightens home-path collapsing.
Changes:
- Adds POSIX-safe single-quote escaping.
- Prevents false tilde-path collapses.
- Adds path-boundary regression tests.
File summaries
| File | Review |
|---|---|
src/vs/platform/terminal/test/common/terminalEnvironment.test.ts |
Adds tilde-collapse tests, but shell-escaping expectations and bothQuotes coverage require updates. |
src/vs/platform/terminal/common/terminalEnvironment.ts |
Updates shell escaping and home-path matching; current changes conflict with existing Bash, Zsh, Git Bash, and sh assertions. |
Review details
Suppressed comments (1)
src/vs/platform/terminal/common/terminalEnvironment.ts:69
- The default branch now returns
'/foo/bar'\''baz', butterminalEnvironment.test.ts:97still asserts the previous'/foo/bar\'baz'output. This leaves the unit suite failing; update the default-shell expectation to the new POSIX form.
bothQuotes: (path) => `'${path.replace(/'/g, `'\\''`)}'`,
singleQuotes: (path) => `'${path.replace(/'/g, `'\\''`)}'`,
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+35
to
+36
| bothQuotes: (path) => `'${path.replace(/'/g, `'\\''`)}'`, | ||
| singleQuotes: (path) => `'${path.replace(/'/g, `'\\''`)}'`, |
| escapeConfig = { | ||
| bothQuotes: (path) => `$'${path.replace(/'/g, '\\\'')}'`, | ||
| singleQuotes: (path) => `'${path.replace(/'/g, '\\\'')}'`, | ||
| singleQuotes: (path) => `$'${path.replace(/'/g, '\\\'')}'`, |
…aping POSIX sh does not support ANSI-C $'...' quoting. When a path contains a single quote, the existing code fell through to the Bash case and emitted $'...\\'...' which sh rejects. Fix: give PosixShellType.Sh its own case using close-quote/escaped-quote/ reopen-quote: path.replace(/'/g, "'\\''"). Also tighten collapseTildePath to check startsWith(home + separator) so /home/user2 is not collapsed when home is /home/user. Add regression tests for both cases.
- Bash/Zsh/GitBash now use ANSI-C $'...' quoting for single-quote paths - PosixShellType.Sh and unknown shells use POSIX close/escape/reopen - Split bash/sh/zsh test into two suites (different output formats) - Add Sh bothQuotes coverage for paths with both single and double quotes - Update default-shell test to expect POSIX form
Viraj Mishra (VirajMishra1)
force-pushed
the
fix-terminal-sh-quoting
branch
from
October 4, 2026 21:22
5890203 to
5886969
Compare
This branch has not been deployed
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 does this implement/fix?
POSIX
shdoes not support ANSI-C$'...'quoting. InescapeNonWindowsPath,PosixShellType.Shwas grouped withBashandZsh, and unknown shells used the same$'...'form for paths that contain both a single and a double quote. In/bin/sh(dash, for example) that is a syntax error.PosixShellType.Shnow has its own case, and the default case uses the same quoting. Both use the POSIX close/escape/reopen idiom, so each'becomes'\''. Bash, Zsh and Git Bash keep$'...'for the both-quotes case.This also changes
collapseTildePathto checkstartsWith(normalizedUserHome + '/')(or equality) instead ofincludes, so/home/user2is not collapsed when home is/home/user, and/tmp/backup/home/user/fileis not collapsed either.Tests
shtest covering a single quote, a double quote and both.collapseTildePathcases for the substring and shared-prefix collisions.I could not run the full suite locally. I checked every
escapeNonWindowsPathexpectation in the test file against the real function output (25 of 25 match).AI usage disclosure
I used AI assistance for: