mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
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 https://github.com/rust-lang/rust/issues/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
This commit is contained in:
parent
d8285f97a8
commit
1420d8a92f
@ -59,8 +59,15 @@ impl Client {
|
||||
} else {
|
||||
Command::new("/bin/sh")
|
||||
};
|
||||
cmd.arg(if cfg!(windows) { "/c" } else { "-c" })
|
||||
.arg(command);
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
cmd.arg("/c").raw_arg(command);
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
cmd.arg("-c").arg(command);
|
||||
}
|
||||
cmd
|
||||
} else {
|
||||
Command::new(command)
|
||||
|
Loading…
Reference in New Issue
Block a user