Skip to content

Commit 1420d8a

Browse files
quark-zjufacebook-github-bot
authored andcommitted
commandserver: fix ui.system on Windows
Summary: The `cmd.exe` does not use the "common" argv[] parsing [1] [2]. For example, the Rust code: Command::new("cmd.exe").arg("/c").arg(r#"notepad "a b.txt"#) will execute (Windows OS command line, as a single string): cmd.exe /c "notepad \"a b.txt\"" which will execute: notepad \"a b.txt\" and notepad will complain that the file cannot be found. To fix it we need to pass the unquoted command and execute either: cmd.exe /c "notepad "a b.txt"" cmd.exe /c notepad "a b.txt" which will execute: notepad "a b.txt" See also rust-lang/rust#29494. [1]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw [2]: https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments Reviewed By: zzl0 Differential Revision: D47242639 fbshipit-source-id: c75aa83430520c29002a095333546cc48695244e
1 parent d8285f9 commit 1420d8a

File tree

1 file changed

+9
-2
lines changed
  • eden/scm/lib/commandserver/src

1 file changed

+9
-2
lines changed

eden/scm/lib/commandserver/src/ipc.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,15 @@ impl Client {
5959
} else {
6060
Command::new("/bin/sh")
6161
};
62-
cmd.arg(if cfg!(windows) { "/c" } else { "-c" })
63-
.arg(command);
62+
#[cfg(windows)]
63+
{
64+
use std::os::windows::process::CommandExt;
65+
cmd.arg("/c").raw_arg(command);
66+
}
67+
#[cfg(not(windows))]
68+
{
69+
cmd.arg("-c").arg(command);
70+
}
6471
cmd
6572
} else {
6673
Command::new(command)

0 commit comments

Comments
 (0)