Skip to content

Commit 5dea766

Browse files
committed
Update documentation for std::process::Command's new method
In the current documentation, it's not specified that when creating a Command, the .exe extension can be omitted for Windows executables. However, for other types of executable files like .bat or .cmd, the complete filename including the extension must be provided. I encountered it by noticing that `Command::new("wt").spawn().unwrap()` succeeds on my machine while `Command::new("code").spawn().unwrap()` panics. Turns out VS Code's entrypoint is .cmd file. `resolve_exe` method mentions this behaviour in a comment[1], but it makes sense to mention it at more visible place. I've added this clarification to the documentation, which should make it more accurate and helpful for Rust developers working on the Windows platform. [1] https://github.com/rust-lang/rust/blob/e7fda447e7d05b6ca431fc8fe8f489b1fda810bc/library/std/src/sys/windows/process.rs#L425
1 parent 6f65ef5 commit 5dea766

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/process.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,14 @@ impl Command {
558558
/// but this has some implementation limitations on Windows
559559
/// (see issue #37519).
560560
///
561+
/// # Platform-specific behavior
562+
///
563+
/// Note on Windows: For executable files with the .exe extension,
564+
/// it can be omitted when specifying the program for this Command.
565+
/// However, if the file has a different extension,
566+
/// a filename including the extension needs to be provided,
567+
/// otherwise the file won't be found.
568+
///
561569
/// # Examples
562570
///
563571
/// Basic usage:

0 commit comments

Comments
 (0)