summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-03 07:08:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-03 07:08:57 -0700
commitd4d626c256dd5147d308e609a9b6c341d8e0a02b (patch)
treee1d5265311cec5ff10cb445b31dc73a59ca7fd6e
parentcfd11a27aed69fec13d76135b45859554bf1f627 (diff)
downloadtxr-d4d626c256dd5147d308e609a9b6c341d8e0a02b.tar.gz
txr-d4d626c256dd5147d308e609a9b6c341d8e0a02b.tar.bz2
txr-d4d626c256dd5147d308e609a9b6c341d8e0a02b.zip
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.
-rw-r--r--txr.c10
1 files 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();