fix: properly quote exe in bash activate#7070
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes shell escaping in bash activation scripts by properly escaping the executable path before interpolation, rather than blindly wrapping it in quotes during interpolation. The change uses shell_escape::unix::escape() to handle special characters in the exe path correctly.
Key changes:
- Added pre-escaping of the
exevariable usingshell_escape::unix::escape() - Removed hard-coded quotes around all
{exe}interpolations in the generated bash script - Applied the same escaping pattern already used by
set_env()andunset_env()methods
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
bugbot run |
|
@cspotcode Could you check if this alternative implementation also solves the problem for you? |
|
@jdx would be good to wait for someone with Windows to confirm. I just saw this while working in this area for a separate reason |
|
I can't, don't have time. I don't see why it wouldn't work. A failing test we can try is if the path to mise contains a single-quote in the path, like if someone installs it into a directory named We can also update the escaping used for other |
|
I'm confident this handles the single quote. I just don't have any experience in the windows world that inspired the other pr. |
I looked at this but each shell has its own quoting rules, and they aren't all compatible with This PR is just to fix a recently-introduced wart in the bash implementation. I am confident in the correctness of this change for Bash. My reason for pause is that the previous fix was targeted at a Windows-specific problem. But having said that, I'm pretty sure it's fine. |
|
@jdx I thought we were still going to merge this. Did you just close it because of apparent staleness? |
|
Oh, I see, this was replaced by a357fa9. Got it! |
Blindly wrapping an interpolated value in quotes is an anti-pattern. Properly quote the value prior to interpolation, instead.
Replaces commit 4a9ec4e from #7002
Note
Escapes the interpolated
exefor bash activation and updates command invocations to use the escaped value without extra quotes.exeviashell_escape::unix::escapebefore interpolation insrc/shell/bash.rs.{exe}without surrounding quotes:mise()function (zero-arg path, eval path, and general command path).command_not_found_handlehook.Written by Cursor Bugbot for commit 728e8ae. This will update automatically on new commits. Configure here.