From 7ba0da7711b986b19945fecdb823c7b7239b87a7 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sun, 17 Jun 2018 11:58:09 -0700 Subject: Fix reading choices if stdin is a tty Previously we deferred reading choices to after initializing the tty. This makes sense only when stdin and our tty aren't the same. --- src/fzy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fzy.c b/src/fzy.c index 23f5673..6b9aa5a 100644 --- a/src/fzy.c +++ b/src/fzy.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "match.h" #include "tty.h" @@ -39,10 +40,15 @@ int main(int argc, char *argv[]) { } } else { /* interactive */ + + if (isatty(STDIN_FILENO)) + choices_fread(&choices, stdin); + tty_t tty; tty_init(&tty, options.tty_filename); - choices_fread(&choices, stdin); + if (!isatty(STDIN_FILENO)) + choices_fread(&choices, stdin); if (options.num_lines > choices.size) options.num_lines = choices.size; -- cgit v1.2.3