Skip to content

Commit 5513284

Browse files
committed
docs: clarify stdout check comment in print_all_env_vars
- Updated the comment to better explain that the path writes via OsWrite, bypassing TrackingWriter, thus requiring an early check to mark stdout as "written" and fail if fd 1 is already closed. This improves code readability and understanding of the stdout-closed handling logic.
1 parent 85a6c7f commit 5513284

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/uucore/src/lib/mods/display.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ impl OsWrite for Box<dyn OsWrite> {
129129
/// This function handles non-UTF-8 environment variable names and values correctly by using
130130
/// raw bytes on Unix systems.
131131
pub fn print_all_env_vars<T: fmt::Display>(line_ending: T) -> io::Result<()> {
132-
// Trigger stdout-closed check and mark "write attempted"; 1 is a non-zero sentinel.
132+
// This path writes via OsWrite and bypasses TrackingWriter, so mark stdout as "written"
133+
// and fail early if fd 1 was already closed.
133134
crate::check_stdout_write(1)?;
134135
let mut stdout = io::stdout().lock();
135136
for (name, value) in env::vars_os() {

0 commit comments

Comments
 (0)