Skip to content

sh: remove unnecessary atty dep #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

joshka
Copy link

@joshka joshka commented Apr 3, 2025

IsTerminal trait was introduced in Rust 1.70

Comment on lines -18 to +21
use std::os::fd::{AsRawFd, RawFd};
use std::time::Duration;
use std::{io::stdin, time::Duration};
use std::{
io::IsTerminal,
os::fd::{AsRawFd, RawFd},
};
Copy link
Author

Choose a reason for hiding this comment

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

This was cargo fmt - I didn't review it. Perhaps consider going with the same decision as the rust standard library does and configuring a rustfmt.toml to group imports by module? This tends to cut down a large number of lines and makes diffs simpler generally.

Copy link
Author

Choose a reason for hiding this comment

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

@jgarzik
Copy link
Contributor

jgarzik commented Apr 3, 2025

Thanks for the patch.

Quick review: ok, but should be applied across entire tree. We don't want to avoid atty in one util, yet use atty in another util.

IsTerminal trait was introduced in Rust 1.70
@joshka
Copy link
Author

joshka commented Apr 3, 2025

Quick review: ok, but should be applied across entire tree. We don't want to avoid atty in one util, yet use atty in another util.

This was the only instance of the atty crate in the main branch (are the other branches active development?).
The atty crate is no longer in the cargo.lock at all:
https://github.com/rustcoreutils/posixutils-rs/blob/fa17a3118e4bfbf3c19e7f04599e8fa80e5d288a/Cargo.lock

There are some calls to use libc::isatty not included in this change (will make another PR), and mention of atty in the contributing doc (which I've removed in 594aa1e).

@joshka
Copy link
Author

joshka commented Apr 3, 2025

Actually - the replacement for the libc::isatty call was relatively simple.

76fa884
cf26e81 - removed libc from the deps for test

Manually tested this with:

target/debug/test -t 0 || echo foo
echo foo target/debug/test -t 0 || echo foo # no output
target/debug/test -t 1 || echo foo
target/debug/test -t 1 1&>/dev/null || echo foo # no output
target/debug/test -t 2 || echo foo
target/debug/test -t 2 2&>/dev/null || echo foo # no output
target/debug/test -t 3 || echo foo # no output
target/debug/test -t 3 3&>/dev/tty || echo foo
target/debug/test -t asdf || echo foo # no output

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.

2 participants