Closed
Description
Description
On Windows, std::process::Command
accepts arbitrary file extensions in place of the correct file extension (typically .exe
) for a command when at least one environment variable is specified (e.g. command.env("FOO", "BAR")
). The issue does not reproduce when no environment variables are specified.
Rust Version
> rustc --version
rustc 1.26.0 (a77568041 2018-05-07)
Minimum repro
use std::process::Command;
fn main() {
Command::new("cmd.bannana")
.env("FOO", "BAR")
.args(&["/c", "echo", "hello"])
.status()
.unwrap();
}
Expected Result
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', libcore\result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\command-ext-err.exe` (exit code: 101)
Actual Result
hello
Negative Reprodution
The following code snippet does NOT reproduce the issue.
use std::process::Command;
fn main() {
Command::new("cmd.bannana")
.args(&["/c", "echo", "hello"])
.status()
.unwrap();
}