Skip to content

Commit f7c2d11

Browse files
committed
doc: Point to methods on Command as alternatives to set/remove_var
1 parent 73c0ae6 commit f7c2d11

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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)