-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-windowsOperating system: WindowsOperating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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
helloNegative 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();
}Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-windowsOperating system: WindowsOperating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.