-
Notifications
You must be signed in to change notification settings - Fork 28
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
base: main
Are you sure you want to change the base?
Conversation
use std::os::fd::{AsRawFd, RawFd}; | ||
use std::time::Duration; | ||
use std::{io::stdin, time::Duration}; | ||
use std::{ | ||
io::IsTerminal, | ||
os::fd::{AsRawFd, RawFd}, | ||
}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
This was the only instance of the atty crate in the main branch (are the other branches active development?). 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). |
Actually - the replacement for the libc::isatty call was relatively simple. 76fa884 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 |
IsTerminal trait was introduced in Rust 1.70