File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -868,13 +868,17 @@ impl Command {
868868 ///
869869 /// # Examples
870870 ///
871+ /// Prevent any inherited `GIT_DIR` variable from changing the target of the `git` command,
872+ /// while allowing all other variables, like `GIT_AUTHOR_NAME`.
873+ ///
871874 /// ```no_run
872875 /// use std::process::Command;
873876 ///
874- /// Command::new("ls")
875- /// .env_remove("PATH")
876- /// .spawn()
877- /// .expect("ls command failed to start");
877+ /// Command::new("git")
878+ /// .arg("commit")
879+ /// .env_remove("GIT_DIR")
880+ /// .spawn()?;
881+ /// # std::io::Result::Ok(())
878882 /// ```
879883 #[ stable( feature = "process" , since = "1.0.0" ) ]
880884 pub fn env_remove < K : AsRef < OsStr > > ( & mut self , key : K ) -> & mut Command {
@@ -896,13 +900,17 @@ impl Command {
896900 ///
897901 /// # Examples
898902 ///
903+ /// The behavior of `sort` is affected by `LANG` and `LC_*` environment variables.
904+ /// Clearing the environment makes `sort`'s behavior independent of the parent processes' language.
905+ ///
899906 /// ```no_run
900907 /// use std::process::Command;
901908 ///
902- /// Command::new("ls")
909+ /// Command::new("sort")
910+ /// .arg("file.txt")
903911 /// .env_clear()
904- /// .spawn()
905- /// .expect("ls command failed to start");
912+ /// .spawn()?;
913+ /// # std::io::Result::Ok(())
906914 /// ```
907915 #[ stable( feature = "process" , since = "1.0.0" ) ]
908916 pub fn env_clear ( & mut self ) -> & mut Command {
You can’t perform that action at this time.
0 commit comments