diff --git a/src/main.cpp b/src/main.cpp index 460960d..2f6b028 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #define STRINGIZE_IMPL(s) #s @@ -88,8 +89,19 @@ namespace { std::string getCleanHtml (const std::string& parUrl, const po::variables_map& parVarMap) { std::string tidyHtml; + struct stat stats; - if (isatty(fileno(stdin))) { + const int r = fstat(fileno(stdin), &stats); + bool interactive = true; + if (r < 0) { + //TODO: error + interactive = false; + } + else { + interactive = static_cast(S_ISCHR(stats.st_mode)); + } + + if (interactive) { tidyHtml = duck::getCleanHtml( parUrl, false,