Skip to content

Commit e7f5366

Browse files
authored
Rollup merge of #135626 - clubby789:env-note, r=ibraheemdev
doc: Point to methods on `Command` as alternatives to `set/remove_var` Make these methods more discoverable, as configuring a child process is a common reason for manipulating the environment.
2 parents bdd88dd + f7c2d11 commit e7f5366

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: library/std/src/env.rs

+8
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ impl Error for VarError {
336336
/// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
337337
/// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
338338
///
339+
/// To pass an environment variable to a child process, you can instead use [`Command::env`].
340+
///
339341
/// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs
342+
/// [`Command::env`]: crate::process::Command::env
340343
///
341344
/// # Panics
342345
///
@@ -396,7 +399,12 @@ pub unsafe fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
396399
/// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
397400
/// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
398401
///
402+
/// To prevent a child process from inheriting an environment variable, you can
403+
/// instead use [`Command::env_remove`] or [`Command::env_clear`].
404+
///
399405
/// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs
406+
/// [`Command::env_remove`]: crate::process::Command::env_remove
407+
/// [`Command::env_clear`]: crate::process::Command::env_clear
400408
///
401409
/// # Panics
402410
///

0 commit comments

Comments
 (0)