summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2018-06-17 11:58:09 -0700
committerJohn Hawthorn <john@hawthorn.email>2018-06-17 12:22:44 -0700
commit7ba0da7711b986b19945fecdb823c7b7239b87a7 (patch)
tree3b253182f9583ed946786ca4dcde7175935f77eb /src
parent794dc0c06cfc1ea60cf97d98c65bb14b47aa3a69 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/fzy.c8
1 files changed, 7 insertions, 1 deletions
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 <stdlib.h>
#include <ctype.h>
#include <limits.h>
+#include <unistd.h>
#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;