Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomcc

Use an absolute path to the NUL device

While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly.

This will also set a good example for people copying std code.

r? libs
This commit is contained in:
Matthias Krüger 2023-11-24 08:23:53 +01:00 committed by GitHub
commit b2d6480f53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -597,7 +597,7 @@ impl Stdio {
opts.read(stdio_id == c::STD_INPUT_HANDLE);
opts.write(stdio_id != c::STD_INPUT_HANDLE);
opts.security_attributes(&mut sa);
File::open(Path::new("NUL"), &opts).map(|file| file.into_inner())
File::open(Path::new(r"\\.\NUL"), &opts).map(|file| file.into_inner())
}
}
}