From 77f17857e7da71fc1b18f9c3e1d7c10e5026e56c Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 20 Apr 2011 11:56:02 +1000 Subject: [PATCH] Use STDOUT when no filename is specified and we detect stdout is not going to the terminal. --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 12c5f12..18a934e 100644 --- a/main.c +++ b/main.c @@ -727,8 +727,10 @@ int main(int argc, char *argv[]) register_outputfile(control.msgout); } - /* If we're using stdin and no output filename, use stdout */ - if (STDIN && !control.outname) { + /* If no output filename is specified, and we're using stdin, + * or we detect that stdout is not going to the terminal, + * use stdout */ + if (!control.outname && (STDIN || !isatty(fileno((FILE *)stdout)))) { control.flags |= FLAG_STDOUT; control.msgout = stderr; register_outputfile(control.msgout);