ls: move from isatty (deprecated) to atty (#1685)

This commit is contained in:
Sylvestre Ledru 2021-01-09 21:21:02 +01:00 committed by GitHub
parent 138e407071
commit d9580c2f3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 17 deletions

14
Cargo.lock generated
View file

@ -668,17 +668,6 @@ name = "ioctl-sys"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "isatty"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itertools"
version = "0.8.2"
@ -1776,8 +1765,8 @@ dependencies = [
name = "uu_ls"
version = "0.0.1"
dependencies = [
"atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"number_prefix 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term_grid 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2585,7 +2574,6 @@ dependencies = [
"checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa"
"checksum hostname 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
"checksum ioctl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e2c4b26352496eaaa8ca7cfa9bd99e93419d3f7983dc6e99c2a35fe9e33504a"
"checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc"
"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
"checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
"checksum itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"

View file

@ -16,7 +16,6 @@ path = "src/ls.rs"
[dependencies]
getopts = "0.2.18"
isatty = "0.1"
lazy_static = "1.0.1"
number_prefix = "0.4"
term_grid = "0.1.5"
@ -26,6 +25,9 @@ unicode-width = "0.1.5"
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries", "fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(unix)'.dependencies]
atty = "0.2"
[[bin]]
name = "ls"
path = "src/main.rs"

View file

@ -13,8 +13,6 @@ extern crate lazy_static;
#[macro_use]
extern crate uucore;
#[cfg(unix)]
use isatty::stdout_isatty;
use number_prefix::NumberPrefix;
use std::cmp::Reverse;
#[cfg(unix)]
@ -627,7 +625,7 @@ fn display_file_name(
None => true,
Some(val) => match val.as_ref() {
"always" | "yes" | "force" => true,
"auto" | "tty" | "if-tty" => stdout_isatty(),
"auto" | "tty" | "if-tty" => atty::is(atty::Stream::Stdout),
/* "never" | "no" | "none" | */ _ => false,
},
};