From 4992cb9b8616af5dd9fe52daa1e61641e66f37f4 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 4 Sep 2023 10:35:17 +0200 Subject: [PATCH] Use std::io::IsTerminal instead of is-terminal --- Cargo.lock | 8 -------- Cargo.toml | 2 -- src/uu/cat/Cargo.toml | 1 - src/uu/cat/src/cat.rs | 3 +-- src/uu/cut/Cargo.toml | 1 - src/uu/cut/src/cut.rs | 3 +-- src/uu/ls/Cargo.toml | 1 - src/uu/ls/src/ls.rs | 3 +-- src/uu/more/Cargo.toml | 1 - src/uu/more/src/more.rs | 3 +-- src/uu/nohup/Cargo.toml | 1 - src/uu/nohup/src/nohup.rs | 3 +-- src/uu/tail/Cargo.toml | 1 - src/uu/tail/src/args.rs | 2 +- src/uu/tty/Cargo.toml | 1 - src/uu/tty/src/tty.rs | 3 +-- tests/by-util/test_more.rs | 2 +- 17 files changed, 8 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4885faa0..55879e585 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -389,7 +389,6 @@ dependencies = [ "filetime", "glob", "hex-literal", - "is-terminal", "libc", "nix", "once_cell", @@ -2311,7 +2310,6 @@ name = "uu_cat" version = "0.0.21" dependencies = [ "clap", - "is-terminal", "nix", "thiserror", "uucore", @@ -2411,7 +2409,6 @@ version = "0.0.21" dependencies = [ "bstr", "clap", - "is-terminal", "memchr", "uucore", ] @@ -2679,7 +2676,6 @@ dependencies = [ "chrono", "clap", "glob", - "is-terminal", "lscolors", "number_prefix", "once_cell", @@ -2732,7 +2728,6 @@ version = "0.0.21" dependencies = [ "clap", "crossterm", - "is-terminal", "nix", "unicode-segmentation", "unicode-width", @@ -2773,7 +2768,6 @@ name = "uu_nohup" version = "0.0.21" dependencies = [ "clap", - "is-terminal", "libc", "uucore", ] @@ -3072,7 +3066,6 @@ version = "0.0.21" dependencies = [ "clap", "fundu", - "is-terminal", "libc", "memchr", "notify", @@ -3162,7 +3155,6 @@ name = "uu_tty" version = "0.0.21" dependencies = [ "clap", - "is-terminal", "nix", "uucore", ] diff --git a/Cargo.toml b/Cargo.toml index 8d658c299..405ed08f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,7 +286,6 @@ gcd = "2.3" glob = "0.3.1" half = "2.2" indicatif = "0.17" -is-terminal = "0.4.9" itertools = "0.11.0" libc = "0.2.147" lscolors = { version = "0.15.0", default-features = false, features = [ @@ -491,7 +490,6 @@ time = { workspace = true, features = ["local-offset"] } unindent = "0.2" uucore = { workspace = true, features = ["entries", "process", "signals"] } walkdir = { workspace = true } -is-terminal = { workspace = true } hex-literal = "0.4.1" rstest = { workspace = true } diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index d67cd1b25..166e1823b 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -17,7 +17,6 @@ path = "src/cat.rs" [dependencies] clap = { workspace = true } thiserror = { workspace = true } -is-terminal = { workspace = true } uucore = { workspace = true, features = ["fs", "pipes"] } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 8ce805251..d49f4aa07 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -7,9 +7,8 @@ // last synced with: cat (GNU coreutils) 8.13 use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; use std::fs::{metadata, File}; -use std::io::{self, Read, Write}; +use std::io::{self, IsTerminal, Read, Write}; use thiserror::Error; use uucore::display::Quotable; use uucore::error::UResult; diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index affeb3805..a55ce7d58 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -19,7 +19,6 @@ clap = { workspace = true } uucore = { workspace = true, features = ["ranges"] } memchr = { workspace = true } bstr = { workspace = true } -is-terminal = { workspace = true } [[bin]] name = "cut" diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 891281753..4d3145c05 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -7,9 +7,8 @@ use bstr::io::BufReadExt; use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; use std::fs::File; -use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write}; +use std::io::{stdin, stdout, BufReader, BufWriter, IsTerminal, Read, Write}; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError}; diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index b1114644d..f3fc2eb6b 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -25,7 +25,6 @@ glob = { workspace = true } lscolors = { workspace = true } uucore = { workspace = true, features = ["entries", "fs"] } once_cell = { workspace = true } -is-terminal = { workspace = true } selinux = { workspace = true, optional = true } [[bin]] diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 1f5165e83..652b978a5 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -10,12 +10,11 @@ use clap::{ crate_version, Arg, ArgAction, Command, }; use glob::{MatchOptions, Pattern}; -use is_terminal::IsTerminal; use lscolors::LsColors; use number_prefix::NumberPrefix; use once_cell::unsync::OnceCell; -use std::collections::HashSet; use std::num::IntErrorKind; +use std::{collections::HashSet, io::IsTerminal}; #[cfg(windows)] use std::os::windows::fs::MetadataExt; diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index ef2240133..bc0f25217 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -18,7 +18,6 @@ path = "src/more.rs" clap = { workspace = true } uucore = { workspace = true } crossterm = { workspace = true } -is-terminal = { workspace = true } unicode-width = { workspace = true } unicode-segmentation = { workspace = true } diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 75cf79c07..02ed0feea 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -7,7 +7,7 @@ use std::{ fs::File, - io::{stdin, stdout, BufReader, Read, Stdout, Write}, + io::{stdin, stdout, BufReader, IsTerminal, Read, Stdout, Write}, path::Path, time::Duration, }; @@ -22,7 +22,6 @@ use crossterm::{ terminal::{self, Clear, ClearType}, }; -use is_terminal::IsTerminal; use unicode_segmentation::UnicodeSegmentation; use unicode_width::UnicodeWidthStr; use uucore::display::Quotable; diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index 2a454b9f4..9fbf125bf 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -17,7 +17,6 @@ path = "src/nohup.rs" [dependencies] clap = { workspace = true } libc = { workspace = true } -is-terminal = { workspace = true } uucore = { workspace = true, features = ["fs"] } [[bin]] diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index fdbed9395..c64f7bf71 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -6,14 +6,13 @@ // spell-checker:ignore (ToDO) execvp SIGHUP cproc vprocmgr cstrs homeout use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; use libc::{c_char, dup2, execvp, signal}; use libc::{SIGHUP, SIG_IGN}; use std::env; use std::ffi::CString; use std::fmt::{Display, Formatter}; use std::fs::{File, OpenOptions}; -use std::io::Error; +use std::io::{Error, IsTerminal}; use std::os::unix::prelude::*; use std::path::{Path, PathBuf}; use uucore::display::Quotable; diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 792b7fcf1..5ff532e60 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -22,7 +22,6 @@ memchr = { workspace = true } notify = { workspace = true } uucore = { workspace = true } same-file = { workspace = true } -is-terminal = { workspace = true } fundu = { workspace = true } [target.'cfg(windows)'.dependencies] diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 795652f26..388842a14 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -10,9 +10,9 @@ use crate::{parse, platform, Quotable}; use clap::{crate_version, value_parser}; use clap::{Arg, ArgAction, ArgMatches, Command}; use fundu::{DurationParser, SaturatingInto}; -use is_terminal::IsTerminal; use same_file::Handle; use std::ffi::OsString; +use std::io::IsTerminal; use std::time::Duration; use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::parse_size::{parse_size, ParseSizeError}; diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index fde233250..917d04c10 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -17,7 +17,6 @@ path = "src/tty.rs" [dependencies] clap = { workspace = true } nix = { workspace = true, features = ["term"] } -is-terminal = { workspace = true } uucore = { workspace = true, features = ["fs"] } [[bin]] diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 96d851d37..efda4a7be 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -8,8 +8,7 @@ // spell-checker:ignore (ToDO) ttyname filedesc use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; -use std::io::Write; +use std::io::{IsTerminal, Write}; use std::os::unix::io::AsRawFd; use uucore::error::{set_exit_code, UResult}; use uucore::{format_usage, help_about, help_usage}; diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index b6ded2298..e80020d39 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. use crate::common::util::TestScenario; -use is_terminal::IsTerminal; +use std::io::IsTerminal; #[test] fn test_more_no_arg() {