diff --git a/crates/loggedcmd/src/lib.rs b/crates/loggedcmd/src/lib.rs index 9a809ee..f843394 100644 --- a/crates/loggedcmd/src/lib.rs +++ b/crates/loggedcmd/src/lib.rs @@ -13,7 +13,7 @@ impl LoggedCommand { pub fn new>(arg0: S) -> Self { let arg0 = arg0.as_ref(); LoggedCommand { - cmdline: shell_words::quote(&arg0.to_string_lossy()).to_string(), + cmdline: quote_osstr(arg0), cmd: Command::new(arg0), } } @@ -21,8 +21,7 @@ impl LoggedCommand { pub fn arg>(&mut self, arg: S) -> &mut Self { let arg = arg.as_ref(); self.cmdline.push(' '); - self.cmdline - .push_str(&shell_words::quote(&arg.to_string_lossy())); + self.cmdline.push_str("e_osstr(arg)); self.cmd.arg(arg); self } @@ -107,3 +106,7 @@ pub enum CommandOutputError { source: std::str::Utf8Error, }, } + +fn quote_osstr(s: &OsStr) -> String { + shell_words::quote(&s.to_string_lossy()).to_string() +}