Skip to content

Conversation

@ChrisX101010
Copy link

Fixes #10239

let write_result = match name {
Ok(name) => stdout.write_all_os(name.as_os_str()),
Ok(name) => {
stdout.write_all_os(name.as_os_str())?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(/bin/tty >&- 2>/dev/null); echo $?

This command shows what happens when theres an error in writing to stdout, the error code that GNU is expecting is 3, but by adding that ? it will make it handled and return a 1. You can get around this by doing:

Ok(name) => stdout
    .write_all_os(name.as_os_str())
    .and_then(|_| writeln!(stdout)),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target/debug/tty > /dev/full silently returns 3. But GNU have tty: write error: No space left on device.

@ChrisX101010
Copy link
Author

@ChrisDryden can you check now, sir? thank you!

@oech3
Copy link
Contributor

oech3 commented Jan 15, 2026

Would you add test to check newline (and exit code of >/dev/full if possible ) to
https://github.com/uutils/coreutils/blob/main/tests/by-util/test_tty.rs ? Thankyou.

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tty: missing newline

3 participants