Selaa lähdekoodia

fix: query stdout terminal size to see if the output gose to a tty.

`terminal_size::terminal_size()` is used to determine if stdout is
connected to a real tty/pty. In previous version of `terminal-size`,
this method only queries the terminal size for `stdout`.
However, it is changed in the following commit
https://github.com/eminence/terminal-size/commit/08f0e73926c11adc3105dbf4eb84dd8c9e6c873a
Now the method will use `stdout, stdin, stderr`, trying its best to
determine the terminal size. This cannot be used to determine if `eza`
output is piped or redirected.
We should use `terminal_size_using_fd` on `stdout.as_raw_fd` instead.

Resolves #434 Fixes #433
hehelego 2 vuotta sitten
vanhempi
sitoutus
427f9759d0
1 muutettua tiedostoa jossa 4 lisäystä ja 3 poistoa
  1. 4 3
      src/main.rs

+ 4 - 3
src/main.rs

@@ -24,6 +24,7 @@
 use std::env;
 use std::ffi::{OsStr, OsString};
 use std::io::{self, ErrorKind, Write};
+use std::os::fd::AsRawFd;
 use std::path::{Component, PathBuf};
 use std::process::exit;
 
@@ -71,9 +72,9 @@ fn main() {
             let writer = io::stdout();
 
             let console_width = options.view.width.actual_terminal_width();
-            let theme = options
-                .theme
-                .to_theme(terminal_size::terminal_size().is_some());
+            let stdout_istty =
+                terminal_size::terminal_size_using_fd(io::stdout().as_raw_fd()).is_some();
+            let theme = options.theme.to_theme(stdout_istty);
             let exa = Exa {
                 options,
                 writer,