Skip to content

Commit a257ceb

Browse files
authored
Rollup merge of rust-lang#84551 - r00ster91:patch-4, r=yaahc
Unify the docs of std::env::{args_os, args} more I noticed that `args_os` was missing some information and I thought it should mention `args` for when you want more safety just like how `args` mentions `args_os` if you don't want it to panic on invalid Unicode.
2 parents 6a35a16 + 7468ee1 commit a257ceb

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

std/src/env.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -710,14 +710,14 @@ pub struct ArgsOs {
710710
/// passed as-is.
711711
///
712712
/// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`.
713-
/// Glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
713+
/// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
714714
/// extension. This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it
715715
/// does on macOS and Windows.
716716
///
717717
/// # Panics
718718
///
719719
/// The returned iterator will panic during iteration if any argument to the
720-
/// process is not valid unicode. If this is not desired,
720+
/// process is not valid Unicode. If this is not desired,
721721
/// use the [`args_os`] function instead.
722722
///
723723
/// # Examples
@@ -735,17 +735,25 @@ pub fn args() -> Args {
735735
Args { inner: args_os() }
736736
}
737737

738-
/// Returns the arguments which this program was started with (normally passed
738+
/// Returns the arguments that this program was started with (normally passed
739739
/// via the command line).
740740
///
741741
/// The first element is traditionally the path of the executable, but it can be
742-
/// set to arbitrary text, and it may not even exist, so this property should
742+
/// set to arbitrary text, and may not even exist. This means this property should
743743
/// not be relied upon for security purposes.
744744
///
745-
/// On glibc Linux systems, arguments are retrieved by placing a function in ".init_array".
746-
/// Glibc passes argc, argv, and envp to functions in ".init_array", as a non-standard extension.
747-
/// This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it does on macOS
748-
/// and Windows.
745+
/// On Unix systems the shell usually expands unquoted arguments with glob patterns
746+
/// (such as `*` and `?`). On Windows this is not done, and such arguments are
747+
/// passed as-is.
748+
///
749+
/// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`.
750+
/// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
751+
/// extension. This allows `std::env::args_os` to work even in a `cdylib` or `staticlib`, as it
752+
/// does on macOS and Windows.
753+
///
754+
/// Note that the returned iterator will not check if the arguments to the
755+
/// process are valid Unicode. To ensure UTF-8 validity,
756+
/// use the [`args`] function instead.
749757
///
750758
/// # Examples
751759
///

0 commit comments

Comments
 (0)