Skip to content

Commit 46cf0e0

Browse files
AxelMontiniphil-opp
authored andcommitted
Apply escape only on windows. (#8)
1 parent 6936a21 commit 46cf0e0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,23 @@ pub fn write(path: &Path, contents: &str) -> Result<()> {
101101
.chain_err(|| format!("couldn't write to {}", p))
102102
}
103103

104+
/// Escapes spaces (` `) in the given input with `%20` or does nothing. Then
105+
/// it returns the processed string.
106+
/// ### Windows Only
107+
/// Doesn't do anything on non-windows systems because escaped output
108+
/// (containing `\ `) is still treated as two arguments because of the
109+
/// remaining space character.
104110
pub fn escape_argument_spaces<S: Into<String>>(arg: S) -> String {
105111
#[cfg(target_os = "windows")]
106112
let escaped = arg.into().replace(" ", "%20");
107113

108114
#[cfg(not(target_os = "windows"))]
115+
let escaped = arg.into();
116+
// Doesn't work because there's still a space character in the string
117+
// and it's still interpreted as a separation between two arguments.
118+
/*
109119
let escaped = arg.into().replace(" ", "\\ ");
120+
*/
110121

111122
escaped
112123
}

0 commit comments

Comments
 (0)