summaryrefslogtreecommitdiffstats
path: root/src/init/mod.rs
diff options
context:
space:
mode:
authorDavid Knaack <davidkna@users.noreply.github.com>2021-07-16 21:20:59 +0200
committerGitHub <noreply@github.com>2021-07-16 15:20:59 -0400
commit1eaf996a3645704910ea30b0ee19a97ab4f1daf6 (patch)
tree91345555c552039d24615f2251bfd3db9187c6e6 /src/init/mod.rs
parente1fc137dc9b7fe4f992884b9984d8c1dba103370 (diff)
fix(windows): avoid inadvertly running exes from cwd (#2885)
On Windows when running commands with their name instead of the path with Command::new, executable with that name from the current working directory will be executed. This PR replaces all instances of Command::new with a new create_command function which will first resolve any executable paths and avoid this issue.
Diffstat (limited to 'src/init/mod.rs')
-rw-r--r--src/init/mod.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/init/mod.rs b/src/init/mod.rs
index dfe360b43..893a063c7 100644
--- a/src/init/mod.rs
+++ b/src/init/mod.rs
@@ -1,3 +1,4 @@
+use crate::utils::create_command;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::{env, io};
@@ -51,9 +52,7 @@ impl StarshipPath {
return self.sprint();
}
let str_path = self.str_path()?;
- let res = std::process::Command::new("cygpath.exe")
- .arg(str_path)
- .output();
+ let res = create_command("cygpath").and_then(|mut cmd| cmd.arg(str_path).output());
let output = match res {
Ok(output) => output,
Err(e) => {