Skip to content

Commit a1c4191

Browse files
authored
fix: allow --paths-cmd to run on Windows (#23)
* fix: allow path comands to run on Windows * Call command * Parse command * Add empty check * Update git.rs
1 parent 95f360f commit a1c4191

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ blake3 = "1.3.1"
2626
fern = { version = "0.6.1", features = ["colored"] }
2727
chrono = "0.4.19"
2828
dialoguer = "0.10.1"
29+
shell-words = "1.1.0"
2930

3031
[dev-dependencies]
3132
assert_cmd = "2.0.4"

src/git.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ pub fn get_head() -> Result<String> {
1717

1818
pub fn get_paths_from_cmd(paths_cmd: &str) -> Result<Vec<AbsPath>> {
1919
debug!("Running paths_cmd: {}", paths_cmd);
20-
let output = Command::new("sh")
21-
.arg("-c")
22-
.arg(paths_cmd)
20+
if paths_cmd.is_empty() {
21+
return Err(anyhow::Error::msg("paths_cmd is empty. Please provide an executable command."));
22+
}
23+
let argv = shell_words::split(paths_cmd).context("failed to split paths_cmd")?;
24+
debug!("Parsed paths_cmd: {:?}", argv);
25+
26+
let output = Command::new(&argv[0])
27+
.args(&argv[1..])
2328
.output()
2429
.context("failed to run provided paths_cmd")?;
2530

0 commit comments

Comments
 (0)