Check fstats instead of using isatty().
This commit is contained in:
parent
c69252604c
commit
db1311839d
1 changed files with 13 additions and 1 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -11,6 +11,7 @@
|
|||
#include <memory>
|
||||
#include <functional>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iterator>
|
||||
|
||||
#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<bool>(S_ISCHR(stats.st_mode));
|
||||
}
|
||||
|
||||
if (interactive) {
|
||||
tidyHtml = duck::getCleanHtml(
|
||||
parUrl,
|
||||
false,
|
||||
|
|
Loading…
Reference in a new issue