Skip to content

Commit

Permalink
std/process/command: clarify Command::new behavior for programs with …
Browse files Browse the repository at this point in the history
…arguments
  • Loading branch information
jieyouxu committed Apr 10, 2024
1 parent b14d8b2 commit 7717d22
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,22 @@ impl Command {
/// but this has some implementation limitations on Windows
/// (see issue #37519).
///
/// [`Command::new`] is only intended to accept the path of the program. If you pass a program
/// path along with arguments such as `ls -l` for the program `ls` and argument `-l`, it will
/// try to search for `ls -l` literally.
///
/// ```no_run (example demonstrating incorrect usage)
/// use std::process::Command;
///
/// // Does not launch `ls`, will try to launch a program named `ls -l` literally.
/// Command::new("ls -l")
/// .spawn()
/// .unwrap();
/// ```
///
/// The arguments need to be passed separately, such as via [`Command::arg`] or
/// [`Command::args`].
///
/// # Platform-specific behavior
///
/// Note on Windows: For executable files with the .exe extension,
Expand Down

0 comments on commit 7717d22

Please sign in to comment.