Skip to content

Commit

Permalink
Use isatty() from standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed Aug 6, 2023
1 parent 432c0b0 commit e6055fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ path = "src/main.rs"
diffus = "0.10.0"
regex = "1"
lazy_static = "1.4.0"
atty = "0.2.14"
git-version = "0.3.4"
backtrace = "0.3"
bytecount = "0.6.2"
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern crate lazy_static;
use backtrace::Backtrace;
use git_version::git_version;
use line_collector::LineCollector;
use std::io::{self};
use std::io::{self, IsTerminal};
use std::panic;
use std::path;
use std::process::exit;
Expand Down Expand Up @@ -204,7 +204,7 @@ fn panic_handler(panic_info: &panic::PanicInfo) {
}

fn highlight_stream(input: &mut dyn io::Read, no_pager: bool) {
if !atty::is(atty::Stream::Stdout) {
if !io::stdout().is_terminal() {
// We're being piped, just do stdin -> stdout
highlight_diff(input, io::stdout());
return;
Expand Down Expand Up @@ -375,7 +375,7 @@ fn main() {
exit(1);
}

if atty::is(atty::Stream::Stdin) {
if io::stdin().is_terminal() {
eprintln!("ERROR: Expected input from a pipe");
eprintln!();
print_help(&mut io::stderr());
Expand Down

0 comments on commit e6055fd

Please sign in to comment.