mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 19:41:15 -03:00
Use out_is_terminal
This removes some spurious unsafe and some imports. Note: We don't use it in `test`, because that can be asked to check arbitrary file descriptors, while this only checks stdout specifically.
This commit is contained in:
@@ -78,8 +78,7 @@ fn print_colors(
|
||||
|
||||
let term = curses::term();
|
||||
for color_name in args {
|
||||
// Safety: isatty cannot fail.
|
||||
if !streams.out_is_redirected && unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 } {
|
||||
if streams.out_is_terminal() {
|
||||
if let Some(term) = term.as_ref() {
|
||||
print_modifiers(outp, term, bold, underline, italics, dim, reverse, bg);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
use libc::isatty;
|
||||
use libc::STDOUT_FILENO;
|
||||
|
||||
use super::prelude::*;
|
||||
use crate::ffi::{builtin_exists, colorize_shell};
|
||||
use crate::function;
|
||||
@@ -138,7 +135,7 @@ pub fn r#type(
|
||||
props.annotated_definition(arg)
|
||||
));
|
||||
|
||||
if !streams.out_is_redirected && unsafe { isatty(STDOUT_FILENO) == 1 } {
|
||||
if streams.out_is_terminal() {
|
||||
let col = colorize_shell(&def.to_ffi(), parser.pin()).from_ffi();
|
||||
streams.out.append(col);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user