Previously we deferred reading choices to after initializing the tty.
This makes sense only when stdin and our tty aren't the same.
| ... | ... |
@@ -3,6 +3,7 @@ |
| 3 | 3 |
#include <stdlib.h> |
| 4 | 4 |
#include <ctype.h> |
| 5 | 5 |
#include <limits.h> |
| 6 |
+#include <unistd.h> |
|
| 6 | 7 |
|
| 7 | 8 |
#include "match.h" |
| 8 | 9 |
#include "tty.h" |
| ... | ... |
@@ -39,10 +40,15 @@ int main(int argc, char *argv[]) {
|
| 39 | 40 |
} |
| 40 | 41 |
} else {
|
| 41 | 42 |
/* interactive */ |
| 43 |
+ |
|
| 44 |
+ if (isatty(STDIN_FILENO)) |
|
| 45 |
+ choices_fread(&choices, stdin); |
|
| 46 |
+ |
|
| 42 | 47 |
tty_t tty; |
| 43 | 48 |
tty_init(&tty, options.tty_filename); |
| 44 | 49 |
|
| 45 |
- choices_fread(&choices, stdin); |
|
| 50 |
+ if (!isatty(STDIN_FILENO)) |
|
| 51 |
+ choices_fread(&choices, stdin); |
|
| 46 | 52 |
|
| 47 | 53 |
if (options.num_lines > choices.size) |
| 48 | 54 |
options.num_lines = choices.size; |