File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -629,6 +629,26 @@ 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 such as `ls -l` for the program `ls` and argument `-l`, it will
637+ /// try to search for `ls -l` literally.
638+ ///
639+ /// ```no_run (example demonstrating incorrect usage)
640+ /// use std::process::Command;
641+ ///
642+ /// // Does not launch `ls`, will try to launch a program named `ls -l` literally.
643+ /// Command::new("ls -l")
644+ /// .spawn()
645+ /// .unwrap();
646+ /// ```
647+ ///
648+ /// The arguments need to be passed separately, such as via [`arg`] or [`args`].
649+ ///
650+ /// [`arg`]: Self::arg
651+ /// [`args`]: Self::args
632652 #[ stable( feature = "process" , since = "1.0.0" ) ]
633653 pub fn new < S : AsRef < OsStr > > ( program : S ) -> Command {
634654 Command { inner : imp:: Command :: new ( program. as_ref ( ) ) }
You can’t perform that action at this time.
0 commit comments