mirror of
https://github.com/nushell/nushell.git
synced 2024-11-28 19:33:47 +01:00
Use built-in is_terminal instead of is_terminal::is_terminal (#9550)
# Description This PR tries to remove ~atty~ is-terminal from the entire code base, since ~[atty is unmaintained](https://rustsec.org/advisories/RUSTSEC-2021-0145) and~ [`is_terminal` has been stabilized](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#isterminal) in rust 1.70.0. cc @fdncred # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
parent
27dcc3ecc3
commit
ad12018199
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2564,7 +2564,6 @@ dependencies = [
|
|||||||
"criterion",
|
"criterion",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"is-terminal",
|
|
||||||
"log",
|
"log",
|
||||||
"miette",
|
"miette",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
@ -2621,7 +2620,6 @@ dependencies = [
|
|||||||
"crossterm",
|
"crossterm",
|
||||||
"fancy-regex",
|
"fancy-regex",
|
||||||
"fuzzy-matcher",
|
"fuzzy-matcher",
|
||||||
"is-terminal",
|
|
||||||
"is_executable",
|
"is_executable",
|
||||||
"log",
|
"log",
|
||||||
"miette",
|
"miette",
|
||||||
@ -2753,7 +2751,6 @@ dependencies = [
|
|||||||
"htmlescape",
|
"htmlescape",
|
||||||
"indexmap 2.0.0",
|
"indexmap 2.0.0",
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"is-terminal",
|
|
||||||
"itertools",
|
"itertools",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
@ -2956,7 +2953,6 @@ name = "nu-system"
|
|||||||
version = "0.84.1"
|
version = "0.84.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"is-terminal",
|
|
||||||
"libc",
|
"libc",
|
||||||
"libproc",
|
"libproc",
|
||||||
"log",
|
"log",
|
||||||
|
@ -93,7 +93,6 @@ nix = { version = "0.26", default-features = false, features = [
|
|||||||
"fs",
|
"fs",
|
||||||
"term",
|
"term",
|
||||||
] }
|
] }
|
||||||
is-terminal = "0.4.8"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path = "./crates/nu-test-support", version = "0.84.1" }
|
nu-test-support = { path = "./crates/nu-test-support", version = "0.84.1" }
|
||||||
|
@ -32,7 +32,6 @@ crossterm = "0.26"
|
|||||||
fancy-regex = "0.11"
|
fancy-regex = "0.11"
|
||||||
fuzzy-matcher = "0.3"
|
fuzzy-matcher = "0.3"
|
||||||
is_executable = "1.0"
|
is_executable = "1.0"
|
||||||
is-terminal = "0.4.8"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
miette = { version = "5.10", features = ["fancy-no-backtrace"] }
|
miette = { version = "5.10", features = ["fancy-no-backtrace"] }
|
||||||
once_cell = "1.18"
|
once_cell = "1.18"
|
||||||
|
@ -6,7 +6,6 @@ use crate::{
|
|||||||
NuHighlighter, NuValidator, NushellPrompt,
|
NuHighlighter, NuValidator, NushellPrompt,
|
||||||
};
|
};
|
||||||
use crossterm::cursor::SetCursorStyle;
|
use crossterm::cursor::SetCursorStyle;
|
||||||
use is_terminal::IsTerminal;
|
|
||||||
use log::{trace, warn};
|
use log::{trace, warn};
|
||||||
use miette::{ErrReport, IntoDiagnostic, Result};
|
use miette::{ErrReport, IntoDiagnostic, Result};
|
||||||
use nu_cmd_base::util::get_guaranteed_cwd;
|
use nu_cmd_base::util::get_guaranteed_cwd;
|
||||||
@ -26,7 +25,7 @@ use reedline::{
|
|||||||
SqliteBackedHistory, Vi,
|
SqliteBackedHistory, Vi,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
io::{self, Write},
|
io::{self, IsTerminal, Write},
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::atomic::Ordering,
|
sync::atomic::Ordering,
|
||||||
time::Instant,
|
time::Instant,
|
||||||
|
@ -49,7 +49,6 @@ fs_extra = "1.3"
|
|||||||
htmlescape = "0.3"
|
htmlescape = "0.3"
|
||||||
indexmap = "2.0"
|
indexmap = "2.0"
|
||||||
indicatif = "0.17"
|
indicatif = "0.17"
|
||||||
is-terminal = "0.4.8"
|
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
lscolors = { version = "0.15", default-features = false, features = ["nu-ansi-term"] }
|
lscolors = { version = "0.15", default-features = false, features = ["nu-ansi-term"] }
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use is_terminal::IsTerminal;
|
|
||||||
use lscolors::{LsColors, Style};
|
use lscolors::{LsColors, Style};
|
||||||
use nu_color_config::color_from_hex;
|
use nu_color_config::color_from_hex;
|
||||||
use nu_color_config::{StyleComputer, TextStyle};
|
use nu_color_config::{StyleComputer, TextStyle};
|
||||||
@ -15,6 +14,7 @@ use nu_table::{
|
|||||||
TableOutput,
|
TableOutput,
|
||||||
};
|
};
|
||||||
use nu_utils::get_ls_colors;
|
use nu_utils::get_ls_colors;
|
||||||
|
use std::io::IsTerminal;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{path::PathBuf, sync::atomic::AtomicBool};
|
use std::{path::PathBuf, sync::atomic::AtomicBool};
|
||||||
|
@ -18,7 +18,6 @@ log = "0.4"
|
|||||||
|
|
||||||
[target.'cfg(target_family = "unix")'.dependencies]
|
[target.'cfg(target_family = "unix")'.dependencies]
|
||||||
nix = { version = "0.26", default-features = false, features = ["fs", "term", "process", "signal"] }
|
nix = { version = "0.26", default-features = false, features = ["fs", "term", "process", "signal"] }
|
||||||
is-terminal = "0.4.8"
|
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
||||||
procfs = "0.15"
|
procfs = "0.15"
|
||||||
|
@ -83,11 +83,11 @@ impl Drop for ForegroundChild {
|
|||||||
// It's a simpler version of fish shell's external process handling.
|
// It's a simpler version of fish shell's external process handling.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mod fg_process_setup {
|
mod fg_process_setup {
|
||||||
use is_terminal::IsTerminal;
|
|
||||||
use nix::{
|
use nix::{
|
||||||
sys::signal,
|
sys::signal,
|
||||||
unistd::{self, Pid},
|
unistd::{self, Pid},
|
||||||
};
|
};
|
||||||
|
use std::io::IsTerminal;
|
||||||
use std::os::unix::prelude::{CommandExt, RawFd};
|
use std::os::unix::prelude::{CommandExt, RawFd};
|
||||||
|
|
||||||
// TODO: when raising MSRV past 1.63.0, switch to OwnedFd
|
// TODO: when raising MSRV past 1.63.0, switch to OwnedFd
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub(crate) fn acquire_terminal(interactive: bool) {
|
pub(crate) fn acquire_terminal(interactive: bool) {
|
||||||
use is_terminal::IsTerminal;
|
|
||||||
use nix::{
|
use nix::{
|
||||||
errno::Errno,
|
errno::Errno,
|
||||||
sys::signal::{signal, SigHandler, Signal},
|
sys::signal::{signal, SigHandler, Signal},
|
||||||
unistd,
|
unistd,
|
||||||
};
|
};
|
||||||
|
use std::io::IsTerminal;
|
||||||
|
|
||||||
if interactive && std::io::stdin().is_terminal() {
|
if interactive && std::io::stdin().is_terminal() {
|
||||||
// see also: https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html
|
// see also: https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html
|
||||||
|
Loading…
Reference in New Issue
Block a user