Skip to content

Commit 09e26bf

Browse files
committed
feat: use std::io::IsTerminal instead of atty crate
1 parent 6519e71 commit 09e26bf

File tree

14 files changed

+35
-65
lines changed

14 files changed

+35
-65
lines changed

Cargo.lock

Lines changed: 1 addition & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ members = [
2828
]
2929

3030
[workspace.dependencies]
31-
atty = "0.2"
3231
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "cargo"] }
3332
chrono = { version = "0.4", default-features = false, features = ["clock"] }
3433
libc = "0.2"
3534
regex = "1.10"
3635
gettext-rs = { path = "./gettext-rs" }
37-
errno = "0.3"
36+
errno = "0.3"

file/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ plib = { path = "../plib" }
1111
clap.workspace = true
1212
gettext-rs.workspace = true
1313
libc.workspace = true
14-
atty.workspace = true
1514
regex.workspace = true
1615
walkdir = "2"
1716
users = "0.11"

misc/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ repository = "https://github.com/rustcoreutils/posixutils-rs.git"
88

99
[dependencies]
1010
plib = { path = "../plib" }
11-
atty.workspace = true
1211
clap.workspace = true
1312
libc.workspace = true
1413
gettext-rs.workspace = true

process/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ plib = { path = "../plib" }
1111
clap.workspace = true
1212
gettext-rs.workspace = true
1313
libc.workspace = true
14-
atty.workspace = true
1514
dirs = "5.0"
1615

1716
[dev-dependencies]

process/nohup.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use libc::{dup, dup2, SIGHUP, SIG_IGN};
1313
use plib::PROJECT_NAME;
1414
use std::env;
1515
use std::fs::{File, OpenOptions};
16-
use std::io;
16+
use std::io::{self, IsTerminal};
1717
use std::os::unix::io::AsRawFd;
1818
use std::process::{self, Command};
1919

@@ -45,11 +45,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4545
};
4646

4747
// Redirecting stdout and stderr to the nohup.out file if they are connected to a terminal
48-
if atty::is(atty::Stream::Stdout) || atty::is(atty::Stream::Stderr) {
48+
if io::stdout().is_terminal() || io::stderr().is_terminal() {
4949
let nohup_out_file =
5050
get_nohup_out_file().expect("Failed to open nohup.out in current or home directory");
5151

52-
if atty::is(atty::Stream::Stdout) {
52+
if io::stdout().is_terminal() {
5353
let fd = nohup_out_file.0.as_raw_fd();
5454

5555
if unsafe { dup2(fd, libc::STDOUT_FILENO) } == -1 {
@@ -71,7 +71,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7171
}
7272
}
7373

74-
if atty::is(atty::Stream::Stderr) {
74+
if io::stderr().is_terminal() {
7575
let fd = nohup_out_file.0.as_raw_fd();
7676

7777
if unsafe { dup2(fd, libc::STDERR_FILENO) } == -1 {

text/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ chrono.workspace = true
1616
libc.workspace = true
1717
notify-debouncer-full = "0.3"
1818
ctor = "0.2"
19-
atty.workspace = true
2019
diff = "0.1"
2120
dirs = "5.0"
2221
deunicode = "1.6"
@@ -101,4 +100,3 @@ path = "./tsort.rs"
101100
[[bin]]
102101
name = "wc"
103102
path = "./wc.rs"
104-

tree/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ gettext-rs.workspace = true
1414
libc.workspace = true
1515
regex.workspace = true
1616
chrono.workspace = true
17-
atty.workspace = true
1817
errno.workspace = true
1918

2019
[dev-dependencies]
@@ -87,4 +86,3 @@ path = "./touch.rs"
8786
[[bin]]
8887
name = "unlink"
8988
path = "./unlink.rs"
90-

tree/mv.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ use plib::PROJECT_NAME;
1818
use std::{
1919
collections::{HashMap, HashSet},
2020
ffi::CString,
21+
fs,
22+
io::{self, IsTerminal},
2123
os::unix::{ffi::OsStrExt, fs::MetadataExt},
2224
path::{Path, PathBuf},
23-
{fs, io},
2425
};
2526

2627
/// mv - move files
@@ -54,7 +55,7 @@ impl MvConfig {
5455
MvConfig {
5556
force: args.force,
5657
interactive: args.interactive,
57-
is_terminal: atty::is(atty::Stream::Stdin),
58+
is_terminal: io::stdin().is_terminal(),
5859
}
5960
}
6061
}

tree/rm.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleC
1616
use plib::PROJECT_NAME;
1717
use std::{
1818
ffi::CString,
19-
fs, io,
19+
fs,
20+
io::{self, IsTerminal},
2021
os::unix::{ffi::OsStrExt, fs::MetadataExt},
2122
path::{Path, PathBuf},
2223
};
@@ -440,7 +441,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
440441
textdomain(PROJECT_NAME)?;
441442
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
442443

443-
let is_tty = atty::is(atty::Stream::Stdin);
444+
let is_tty = io::stdin().is_terminal();
444445
let cfg = RmConfig { args, is_tty };
445446

446447
let mut exit_code = 0;

0 commit comments

Comments
 (0)