Repository navigation
shell: fish-quote the fish profile line - #24114
Merged
Merged
Conversation
Inside fish single quotes \' and \\ are escapes, so the POSIX '\'' sequence from sh_single_quote left the string unterminated.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add regression coverage for backslash escaping.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates Fish profile command generation to preserve quotes and backslashes safely.
Changes:
- Adds Fish-specific quoting.
- Applies it to Fish profile assignments.
- Adds apostrophe regression coverage.
Review feedback requests a regression test covering backslashes.
| File | Summary |
|---|---|
Library/Homebrew/utils/shell.rb |
Implements and applies Fish-compatible quoting. |
Library/Homebrew/test/utils/shell_spec.rb |
Tests apostrophe handling; backslash coverage remains needed. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
MikeMcQuaid
added a commit
to rawsun007/brew
that referenced
this pull request
Oct 3, 2026
- Revert speculative quoting from Homebrew#24035, Homebrew#24042, Homebrew#24105, Homebrew#24114 and Homebrew#24154 after the author confirmed it lacked user reports. - Revert Homebrew#24053 and Homebrew#24144: repeated singleton headers and rounding boundaries have no reported user failures in their discussions. - Use `Shellwords.escape` and `Process.spawn` instead of maintaining duplicate escaping and process setup logic. - Preserve tilde expansion and csh newline quoting, and reuse the profile map as the supported-shell list. - Inline redirect resolution and headline formatting into their sole callers; exercise redirects through the download strategy. - Retain ordinary PowerShell and mksh fixes, archive validation and runtime migrations that avoid duplicating existing functionality.
MikeMcQuaid
added a commit
to rawsun007/brew
that referenced
this pull request
Oct 3, 2026
- Revert speculative quoting from Homebrew#24035, Homebrew#24042, Homebrew#24105, Homebrew#24114 and Homebrew#24154 after the author confirmed it lacked user reports. - Use `Shellwords.escape` and `Process.spawn` instead of maintaining duplicate escaping and process setup logic. - Preserve tilde expansion and convert Ruby's quoted newlines for csh without changing the backslashes already escaped by Ruby. - Reuse the profile map as the supported-shell list and inline single-use locals while retaining ordinary PowerShell support.
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.

brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Follow-up to #24042, which wrapped every profile line in
sh_single_quote. The line is run by the user's own shell, and for fish that is wrong: inside fish single quotes\'and\\are escapes, so'\''never closes the string.A backslash is also lost silently:
back\slashis written asbackslash.This adds
fish_quoteand uses it for the fish echo. Running each generated command in fish and sourcing the result in fish, 18 values including quotes, backslashes,$, backticks and spaces:maingets 3 wrong, this gets none wrong.prepend_path_in_profileusesfish_add_pathwithsh_quote, which fish reads correctly, so it is unchanged. Reverting the call site fails exactly the new test.AI disclosure: written with Claude Code (Claude Opus 5.5) on my account. I reviewed the diff and will answer review comments myself.