File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -629,6 +629,26 @@ impl Command {
629
629
/// .spawn()
630
630
/// .expect("sh command failed to start");
631
631
/// ```
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
632
652
#[ stable( feature = "process" , since = "1.0.0" ) ]
633
653
pub fn new < S : AsRef < OsStr > > ( program : S ) -> Command {
634
654
Command { inner : imp:: Command :: new ( program. as_ref ( ) ) }
You can’t perform that action at this time.
0 commit comments