summaryrefslogtreecommitdiff
path: root/src/fzy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fzy.c')
-rw-r--r--src/fzy.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fzy.c b/src/fzy.c
index 461f022..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"
@@ -20,16 +21,17 @@ int main(int argc, char *argv[]) {
choices_t choices;
choices_init(&choices, &options);
- choices_fread(&choices, stdin);
if (options.benchmark) {
if (!options.filter) {
fprintf(stderr, "Must specify -e/--show-matches with --benchmark\n");
exit(EXIT_FAILURE);
}
+ choices_fread(&choices, stdin);
for (int i = 0; i < options.benchmark; i++)
choices_search(&choices, options.filter);
} else if (options.filter) {
+ choices_fread(&choices, stdin);
choices_search(&choices, options.filter);
for (size_t i = 0; i < choices_available(&choices); i++) {
if (options.show_scores)
@@ -38,9 +40,16 @@ 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);
+ if (!isatty(STDIN_FILENO))
+ choices_fread(&choices, stdin);
+
if (options.num_lines > choices.size)
options.num_lines = choices.size;