diff options
| author | Chris Denton <christophersdenton@gmail.com> | 2021-12-16 17:21:34 +0000 |
|---|---|---|
| committer | Chris Denton <christophersdenton@gmail.com> | 2021-12-16 17:22:32 +0000 |
| commit | de764a7ccbbcaf90db88569ce7a8b5e2214cfcd8 (patch) | |
| tree | 301ce4897b76506f200d3f2520747ac9f6238cd2 /library/std/src/process | |
| parent | f8402169aaa12e7bbb9630796a8caec90a3055ca (diff) | |
| download | rust-de764a7ccbbcaf90db88569ce7a8b5e2214cfcd8.tar.gz rust-de764a7ccbbcaf90db88569ce7a8b5e2214cfcd8.zip | |
Quote bat script command line
Diffstat (limited to 'library/std/src/process')
| -rw-r--r-- | library/std/src/process/tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index 67b747e4107..630a8a4c47a 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -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!"); +} |
