Skip to content

Commit 4a9ec4e

Browse files
authored
fix: in activate bash output, wrap mise executable path in single-quotes (jdx#7002)
On Windows, the path to `mise.exe` will contain backslashes. Both `busybox.exe bash` and Git-for-Windows' "Git Bash" can understand these backslash paths. But bash syntax rules dictate that unquoted backslashes are interpreted as escapes. We must wrap the path in single-quotes to avoid this. ```bash # In "Git Bash" or "busybox.exe bash" # Backslash paths are accepted $ 'G:\dev\@jdx\mise\target\debug\mise.exe' --version ... 2025.11.5-DEBUG windows-x64 (2025-11-18) # But unqouted is broken # because bash's syntax rules will interpret any unquoted backslashes as escapes $ G:\dev\@jdx\mise\target\debug\mise.exe --version bash: G:[email protected]: not found ``` Quoting is *technically* more correct on Linux, too, even though the issues it avoids -- splitting on spaces -- are largely hypothetical.[^1] I can't think of any way that this code change would break someone's legitimate setup on Linux or Mac. [^1]: To be pedantic, if the path to `mise` includes a single-quote -- if the name of a parent directory has a single-quote in it -- then this will be broken on Linux, but it would *already* be broken before this code change, so we are not making it worse.
1 parent 16a43ed commit 4a9ec4e

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/shell/bash.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Shell for Bash {
3838
local command
3939
command="${{1:-}}"
4040
if [ "$#" = 0 ]; then
41-
command {exe}
41+
command '{exe}'
4242
return
4343
fi
4444
shift
@@ -47,12 +47,12 @@ impl Shell for Bash {
4747
deactivate|shell|sh)
4848
# if argv doesn't contains -h,--help
4949
if [[ ! " $@ " =~ " --help " ]] && [[ ! " $@ " =~ " -h " ]]; then
50-
eval "$(command {exe} "$command" "$@")"
50+
eval "$(command '{exe}' "$command" "$@")"
5151
return $?
5252
fi
5353
;;
5454
esac
55-
command {exe} "$command" "$@"
55+
command '{exe}' "$command" "$@"
5656
}}
5757
5858
_mise_hook() {{
@@ -85,7 +85,7 @@ impl Shell for Bash {
8585
fi
8686
8787
command_not_found_handle() {{
88-
if [[ "$1" != "mise" && "$1" != "mise-"* ]] && {exe} hook-not-found -s bash -- "$1"; then
88+
if [[ "$1" != "mise" && "$1" != "mise-"* ]] && '{exe}' hook-not-found -s bash -- "$1"; then
8989
_mise_hook
9090
"$@"
9191
elif [ -n "$(declare -f _command_not_found_handle)" ]; then

src/shell/snapshots/mise__shell__bash__tests__activate.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mise() {
1414
local command
1515
command="${1:-}"
1616
if [ "$#" = 0 ]; then
17-
command /some/dir/mise
17+
command '/some/dir/mise'
1818
return
1919
fi
2020
shift
@@ -23,12 +23,12 @@ mise() {
2323
deactivate|shell|sh)
2424
# if argv doesn't contains -h,--help
2525
if [[ ! " $@ " =~ " --help " ]] && [[ ! " $@ " =~ " -h " ]]; then
26-
eval "$(command /some/dir/mise "$command" "$@")"
26+
eval "$(command '/some/dir/mise' "$command" "$@")"
2727
return $?
2828
fi
2929
;;
3030
esac
31-
command /some/dir/mise "$command" "$@"
31+
command '/some/dir/mise' "$command" "$@"
3232
}
3333

3434
_mise_hook() {
@@ -77,7 +77,7 @@ if [ -z "${_mise_cmd_not_found:-}" ]; then
7777
fi
7878

7979
command_not_found_handle() {
80-
if [[ "$1" != "mise" && "$1" != "mise-"* ]] && /some/dir/mise hook-not-found -s bash -- "$1"; then
80+
if [[ "$1" != "mise" && "$1" != "mise-"* ]] && '/some/dir/mise' hook-not-found -s bash -- "$1"; then
8181
_mise_hook
8282
"$@"
8383
elif [ -n "$(declare -f _command_not_found_handle)" ]; then

0 commit comments

Comments
 (0)