From 71bfe31002874902e683337dcfa9f8b08932337e Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Tue, 19 Aug 2025 21:39:31 -0400 Subject: [PATCH] Make IS_INTERACTIVE() macro. --- src/files.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/files.c b/src/files.c index c8fe8444..dbefad53 100644 --- a/src/files.c +++ b/src/files.c @@ -278,6 +278,8 @@ int ReadLine(void) return ReadLineFromFile(0); } +#define IS_INTERACTIVE() (fp && fileno(fp) == STDIN_FILENO && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) + /***************************************************************/ /* */ /* ReadLineFromFile */ @@ -304,7 +306,7 @@ static int ReadLineFromFile(int use_pclose) LineNoStart = LineNo+1; while(fp) { #ifdef USE_READLINE - if (fileno(fp) == STDIN_FILENO && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { + if (IS_INTERACTIVE()) { char *lin; if (should_ignore_line()) { if (read_some) { @@ -410,7 +412,7 @@ static int ReadLineFromFile(int use_pclose) } #ifdef USE_READLINE_HISTORY - if (fp && fileno(fp) == STDIN_FILENO && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { + if (IS_INTERACTIVE()) { add_history(CurLine); } #endif