fish_key_reader: reuse isatty helper

This commit is contained in:
Johannes Altmanninger
2025-09-22 11:03:46 +02:00
parent 2d457adfec
commit 76d1e8d4da
2 changed files with 2 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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()`].