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;