Skip to content

Commit ac78720

Browse files
AxelMontiniphil-opp
authored andcommitted
Escape sysroot and manifest paths to remove blank spaces
1 parent 9716bbc commit ac78720

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Rustflags {
4545
pub fn for_xargo(&self, home: &Home) -> String {
4646
let mut flags = self.flags.clone();
4747
flags.push("--sysroot".to_owned());
48-
flags.push(home.display().to_string());
48+
flags.push(util::escape_argument_spaces(format!("{}", home.display())));
4949
flags.join(" ")
5050
}
5151
}

src/sysroot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn build_crate(
105105
}
106106
}
107107
cmd.arg("--manifest-path");
108-
cmd.arg(td.join("Cargo.toml"));
108+
cmd.arg(util::escape_argument_spaces(td.join("Cargo.toml").to_str().expect("This path doesn't contain valid UTF-8 characters")));
109109
cmd.args(&["--target", cmode.orig_triple()]);
110110

111111
if verbose {

src/util.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,13 @@ pub fn write(path: &Path, contents: &str) -> Result<()> {
100100
.write_all(contents.as_bytes())
101101
.chain_err(|| format!("couldn't write to {}", p))
102102
}
103+
104+
pub fn escape_argument_spaces<S: Into<String>>(arg: S) -> String {
105+
#[cfg(target_os = "windows")]
106+
let escaped = arg.into().replace(" ", "%20");
107+
108+
#[cfg(not(target_os = "windows"))]
109+
let escaped = arg.into().replace(" ", "\\ ");
110+
111+
escaped
112+
}

0 commit comments

Comments
 (0)