Quote bat script command line
This commit is contained in:
@@ -416,3 +416,22 @@ fn env_empty() {
|
||||
let p = Command::new("cmd").args(&["/C", "exit 0"]).env_clear().spawn();
|
||||
assert!(p.is_ok());
|
||||
}
|
||||
|
||||
// See issue #91991
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn run_bat_script() {
|
||||
let tempdir = crate::sys_common::io::test::tmpdir();
|
||||
let script_path = tempdir.join("hello.cmd");
|
||||
|
||||
crate::fs::write(&script_path, "@echo Hello, %~1!").unwrap();
|
||||
let output = Command::new(&script_path)
|
||||
.arg("fellow Rustaceans")
|
||||
.stdout(crate::process::Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait_with_output()
|
||||
.unwrap();
|
||||
assert!(output.status.success());
|
||||
assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "Hello, fellow Rustaceans!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user