Skip to content

Commit 9a36474

Browse files
authored
Merge pull request #1167 from notpeelz/refactor-isatty
Replace nix::unistd::isatty with std::io::IsTerminal
2 parents b752de1 + 08f7646 commit 9a36474

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

Diff for: src/config.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::env::consts::ARCH;
1111
use std::env::{remove_var, set_var, var};
1212
use std::fmt;
1313
use std::fs::{remove_file, OpenOptions};
14-
use std::io::{stderr, stdin, stdout, BufRead};
14+
use std::io::{stderr, stdin, stdout, BufRead, IsTerminal};
1515
use std::path::{Path, PathBuf};
1616
use std::str::FromStr;
1717

@@ -25,8 +25,6 @@ use anyhow::{anyhow, bail, ensure, Context, Error, Result};
2525
use bitflags::bitflags;
2626
use cini::{Callback, CallbackKind, Ini};
2727
use globset::{Glob, GlobSet, GlobSetBuilder};
28-
use nix::unistd::isatty;
29-
use std::os::unix::io::AsRawFd;
3028
use tr::tr;
3129
use url::Url;
3230

@@ -106,12 +104,7 @@ pub struct Colors {
106104
impl From<&str> for Colors {
107105
fn from(s: &str) -> Self {
108106
match s {
109-
"auto"
110-
if isatty(stdout().as_raw_fd()).unwrap_or(false)
111-
&& isatty(stderr().as_raw_fd()).unwrap_or(false) =>
112-
{
113-
Colors::new()
114-
}
107+
"auto" if stdout().is_terminal() && stderr().is_terminal() => Colors::new(),
115108
"always" => Colors::new(),
116109
_ => Colors::default(),
117110
}

0 commit comments

Comments
 (0)