From d4d626c256dd5147d308e609a9b6c341d8e0a02b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 3 Aug 2021 07:08:57 -0700 Subject: listener: print banner only if stdin is a tty. * txr.c (banner): If standard input isn't a tty, bail. Now takes a self argument for the c_int function. (txr_main): Pass self value down to banner. --- txr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/txr.c b/txr.c index 843a0713..159218a9 100644 --- a/txr.c +++ b/txr.c @@ -56,6 +56,7 @@ #include "regex.h" #include "arith.h" #include "sysif.h" +#include "itypes.h" #if HAVE_GLOB #include "glob.h" #endif @@ -181,8 +182,11 @@ static void help(void) } #if HAVE_TERMIOS -static void banner(void) +static void banner(val self) { + if (!isatty(c_int(stream_fd(std_input), self))) + return; + format(std_output, if3(opt_noninteractive, lit("This is the TXR Lisp plain mode listener of TXR ~a.\n" @@ -573,7 +577,7 @@ int txr_main(int argc, char **argv) } else if (argc <= 1) { drop_privilege(); #if HAVE_TERMIOS - banner(); + banner(self); goto repl; #else hint(); @@ -1107,7 +1111,7 @@ int txr_main(int argc, char **argv) if (evaled) return EXIT_SUCCESS; #if HAVE_TERMIOS - banner(); + banner(self); goto repl; #else hint(); -- cgit v1.2.3