From 76d1e8d4daf0345947ec5be2f3228705bb01790d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 22 Sep 2025 11:03:46 +0200 Subject: [PATCH] fish_key_reader: reuse isatty helper --- src/builtins/fish_key_reader.rs | 2 +- src/nix.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builtins/fish_key_reader.rs b/src/builtins/fish_key_reader.rs index a899b8ed8..a7c61daca 100644 --- a/src/builtins/fish_key_reader.rs +++ b/src/builtins/fish_key_reader.rs @@ -257,7 +257,7 @@ pub fn fish_key_reader( return s; } - if streams.stdin_fd < 0 || unsafe { libc::isatty(streams.stdin_fd) } == 0 { + if streams.stdin_fd < 0 || !isatty(streams.stdin_fd) { streams.err.appendln("Stdin must be attached to a tty."); return Err(STATUS_CMD_ERROR); } diff --git a/src/nix.rs b/src/nix.rs index 8c9a97d5c..18712ca29 100644 --- a/src/nix.rs +++ b/src/nix.rs @@ -41,7 +41,7 @@ pub fn getpid() -> i32 { pub fn isatty(fd: i32) -> bool { // This returns false if the fd is valid but not a tty, or is invalid. // No place we currently call it really cares about the difference. - return unsafe { libc::isatty(fd) } == 1; + (unsafe { libc::isatty(fd) }) == 1 } /// An enumeration of supported libc rusage types used by [`getrusage()`].