From ea63d5d3c2ddf896e799585b4b03f20c473eb5d4 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 16 Jun 2014 21:28:30 -0500 Subject: [PATCH] No args default w/ tty stdout, not tty stdin #220 --- configure.ac | 3 +++ main.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/configure.ac b/configure.ac index 238405e9..e8dfed42 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,9 @@ EOF AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) +AC_FIND_FUNC([isatty], [c], [#include ], [0]) +AC_FIND_FUNC([_isatty], [c], [#include ], [0]) + AC_ARG_ENABLE([pthread-tls], [AC_HELP_STRING([--enable-pthread-tls], [Enable use of pthread thread local storage])], diff --git a/main.c b/main.c index 066cc7e3..7a7a6ec4 100644 --- a/main.c +++ b/main.c @@ -237,6 +237,18 @@ int main(int argc, char* argv[]) { die(); } } + +#if (!defined(WIN32) && defined(HAVE_ISATTY)) || defined(HAVE__ISATTY) + +#if defined(HAVE__ISATTY) && defined(isatty) +#undef isatty +#define isatty _isatty +#endif + + if (!program && isatty(STDOUT_FILENO) && !isatty(STDIN_FILENO)) + program = "."; +#endif + if (!program) usage(); if (ninput_files == 0) current_input = stdin;