Skip to content

Commit 9844d7f

Browse files
committed
Clarify Command::new behavior if passed programs with arguments
1 parent 06194ca commit 9844d7f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/process.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,16 @@ impl Command {
629629
/// .spawn()
630630
/// .expect("sh command failed to start");
631631
/// ```
632+
///
633+
/// # Caveats
634+
///
635+
/// [`Command::new`] is only intended to accept the path of the program. If you pass a program
636+
/// path along with arguments like `Command::new("ls -l").spawn()`, it will try to search for
637+
/// `ls -l` literally. The arguments need to be passed separately, such as via [`arg`] or
638+
/// [`args`].
639+
///
640+
/// [`arg`]: Self::arg
641+
/// [`args`]: Self::args
632642
#[stable(feature = "process", since = "1.0.0")]
633643
pub fn new<S: AsRef<OsStr>>(program: S) -> Command {
634644
Command { inner: imp::Command::new(program.as_ref()) }

0 commit comments

Comments
 (0)