From ba990c111145f291b618d4b483d55b12cde1e230 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Sat, 18 Apr 2026 12:56:27 +0200 Subject: [PATCH] fish(init/elvish): improve starship path encoding (#7030) --- src/init/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/init/mod.rs b/src/init/mod.rs index 239770895..33af9de00 100644 --- a/src/init/mod.rs +++ b/src/init/mod.rs @@ -50,6 +50,16 @@ impl StarshipPath { .map(|s| s.replace('\'', "''")) .map(|s| format!("'{s}'")) } + + /// `Elvish` specific path escaping + fn sprint_elv(&self) -> io::Result { + // Prefix with `e:` to force elvish to interpret it as an executable path + // also avoids issues with paths starting with `E:` like `E:\path\to\starship.exe` + self.str_path() + .map(|s| format!("e:{s}")) + .map(|s| shell_words::quote(&s).into_owned()) + } + /// Command Shell specific path escaping fn sprint_cmdexe(&self) -> io::Result { self.str_path().map(|s| format!("\"{s}\"")) @@ -168,7 +178,7 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> { "ion" => print!("eval $({} init ion --print-full-init)", starship.sprint()?), "elvish" => print!( r"eval ({} init elvish --print-full-init | slurp)", - starship.sprint()? + starship.sprint_elv()? ), "tcsh" => print!( r"eval `({} init tcsh --print-full-init)`", @@ -215,7 +225,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> { "fish" => print_script(FISH_INIT, &starship_path.sprint_posix()?), "powershell" => print_script(PWSH_INIT, &starship_path.sprint_pwsh()?), "ion" => print_script(ION_INIT, &starship_path.sprint()?), - "elvish" => print_script(ELVISH_INIT, &starship_path.sprint()?), + "elvish" => print_script(ELVISH_INIT, &starship_path.sprint_elv()?), "tcsh" => print_script(TCSH_INIT, &starship_path.sprint_posix()?), "xonsh" => print_script(XONSH_INIT, &starship_path.sprint_posix()?), _ => {