mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00: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:
parent
5f0df359b8
commit
995f12219b
2 changed files with 2 additions and 6 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue