From b06287cce5887d70d06893b831858aafcb76a8ff Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Feb 2011 13:26:51 +1100 Subject: [PATCH] Make it not read stdin from a terminal or write stdout to a terminal unless forced with -f. --- main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.c b/main.c index a8c4135..b397850 100644 --- a/main.c +++ b/main.c @@ -909,6 +909,17 @@ int main(int argc, char *argv[]) sigaction(SIGTERM, &handler, 0); sigaction(SIGINT, &handler, 0); + if (!FORCE_REPLACE) { + if (STDIN && isatty(fileno((FILE *)stdin))) { + print_err("Will not read stdin from a terminal. Use -f to override.\n"); + exit (1); + } + if (STDIN && isatty(fileno((FILE *)stdout))) { + print_err("Will not write stdout to a terminal. Use -f to override.\n"); + exit (1); + } + } + gettimeofday(&start_time, NULL); if (control.flags & (FLAG_DECOMPRESS | FLAG_TEST_ONLY))