garybernhardt / selecta

A fuzzy text selector for files and anything else you need to select. Use it from vim, from the command line, or anywhere you can run a shell command.
MIT License
1.34k stars 81 forks source link

selecta blows up when given input before output is written to stdout #105

Closed Julian closed 6 years ago

Julian commented 6 years ago

I can't tell if this is the same issue as #103 -- I do use both tmux and coreutils on OSX, so it seems suspicious, but for me, things blow up even outside of tmux, so at least that part is different, and the exact reproducer is different as well.

Namely, the following works fine:

⊙  seq 10 | selecta                                                                                                                                                                                                                                                                                                                                 jberman@Home
 1 > 3
3

but if you start to give input on stdin before output has been written, via e.g.:

⊙  { sleep 3; seq 10 } | selecta                                                                                                                                                                                                                                                                                                                    jberman@Home
 2 > 1
1
10

      stty: 'standard input': unable to perform all requested operations
Traceback (most recent call last):
    9: from /usr/local/bin/selecta:839:in `<main>'
    8: from /usr/local/bin/selecta:45:in `main'
    7: from /usr/local/bin/selecta:584:in `with_screen'
    6: from /usr/local/bin/selecta:801:in `with_tty'
    5: from /usr/local/bin/selecta:591:in `block in with_screen'
    4: from /usr/local/bin/selecta:613:in `restore_tty'
    3: from /usr/local/bin/selecta:821:in `stty'
    2: from /usr/local/bin/selecta:828:in `command'
    1: from /usr/local/bin/selecta:828:in `pipe'
/usr/local/bin/selecta:831:in `block in command': Command failed: "stty 6902:3:4b00:5cf:4:ff:ff:7f:17:15:12:0:3:1c:1a:19:11:13:16:f:1:0:14:0" (RuntimeError)

where I typed that 1 before the sleep had exited, then I get the stty invalid operation traceback.

Julian commented 6 years ago

OK, I can though confirm that the problem goes away if I remove /usr/local/opt/coreutils/libexec/gnubin from my path.

Maybe this is the same issue, and #103 possibly left out the detail above.

For now I suppose I'll just alias selecta to remove coreutils from my path I suppose.

garybernhardt commented 6 years ago

Yes, I think it's just #103 again. I don't understand why GNU even provides an stty binary on OS X. My understanding of stty is that it has deep knowledge of the kernel's pty subsystem, so it really only makes sense to use an stty written by the authors of the kernel (in this case, Apple). I'll close this for now, but please reopen it if you encounter anything like this while using the stty shipped with the OS!