File tree Expand file tree Collapse file tree 6 files changed +44
-0
lines changed Expand file tree Collapse file tree 6 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1206,6 +1206,30 @@ impl Command {
12061206 pub fn get_current_dir ( & self ) -> Option < & Path > {
12071207 self . inner . get_current_dir ( )
12081208 }
1209+
1210+ /// Returns whether the environment will be cleared for the child process.
1211+ ///
1212+ /// This returns `true` if [`Command::env_clear`] was called, and `false` otherwise.
1213+ /// When `true`, the child process will not inherit any environment variables from
1214+ /// its parent process.
1215+ ///
1216+ /// # Examples
1217+ ///
1218+ /// ```
1219+ /// #![feature(command_resolved_envs)]
1220+ /// use std::process::Command;
1221+ ///
1222+ /// let mut cmd = Command::new("ls");
1223+ /// assert_eq!(cmd.get_env_clear(), false);
1224+ ///
1225+ /// cmd.env_clear();
1226+ /// assert_eq!(cmd.get_env_clear(), true);
1227+ /// ```
1228+ #[ must_use]
1229+ #[ unstable( feature = "command_resolved_envs" , issue = "149070" ) ]
1230+ pub fn get_env_clear ( & self ) -> bool {
1231+ self . inner . get_env_clear ( )
1232+ }
12091233}
12101234
12111235#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ impl Command {
9898 self . env . iter ( )
9999 }
100100
101+ pub fn get_env_clear ( & self ) -> bool {
102+ self . env . does_clear ( )
103+ }
104+
101105 pub fn get_current_dir ( & self ) -> Option < & Path > {
102106 self . cwd . as_ref ( ) . map ( Path :: new)
103107 }
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ impl Command {
8383 self . env . iter ( )
8484 }
8585
86+ pub fn get_env_clear ( & self ) -> bool {
87+ self . env . does_clear ( )
88+ }
89+
8690 pub fn get_current_dir ( & self ) -> Option < & Path > {
8791 None
8892 }
Original file line number Diff line number Diff line change @@ -263,6 +263,10 @@ impl Command {
263263 self . env . iter ( )
264264 }
265265
266+ pub fn get_env_clear ( & self ) -> bool {
267+ self . env . does_clear ( )
268+ }
269+
266270 pub fn get_current_dir ( & self ) -> Option < & Path > {
267271 self . cwd . as_ref ( ) . map ( |cs| Path :: new ( OsStr :: from_bytes ( cs. as_bytes ( ) ) ) )
268272 }
Original file line number Diff line number Diff line change @@ -86,6 +86,10 @@ impl Command {
8686 self . env . iter ( )
8787 }
8888
89+ pub fn get_env_clear ( & self ) -> bool {
90+ self . env . does_clear ( )
91+ }
92+
8993 pub fn get_current_dir ( & self ) -> Option < & Path > {
9094 self . cwd . as_ref ( ) . map ( |cs| Path :: new ( cs) )
9195 }
Original file line number Diff line number Diff line change @@ -250,6 +250,10 @@ impl Command {
250250 self . env . iter ( )
251251 }
252252
253+ pub fn get_env_clear ( & self ) -> bool {
254+ self . env . does_clear ( )
255+ }
256+
253257 pub fn get_current_dir ( & self ) -> Option < & Path > {
254258 self . cwd . as_ref ( ) . map ( Path :: new)
255259 }
You can’t perform that action at this time.
0 commit comments