AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 350 forks source link

fix: ensure terminal has required read settings in non-canonical mode #409

Closed mgabeler-lee-6rs closed 2 years ago

mgabeler-lee-6rs commented 2 years ago

When taking the terminal out of canonical mode, the VMIN and VTIME values become important. The rest of the code in this repo (unsurprisingly) expects the terminal to still operate in blocking read mode. However in some situations, notably in some screen sessions (for unknown reasons), VMIN and VTIME may be set to 0 initially, which produces a range of errors, most commonly "false" EOF reports, but also sometimes panics.

The bug this fixes can be reproduced without messing about with screen simply by running stty min 0 time 0 before running any app that uses this library. A trivial test app I made to debug this issue is available at https://github.com/mgabeler-lee-6rs/survey-screen-eof-demo

fixes #408 see also https://github.com/cli/cli/issues/4739

mislav commented 2 years ago

The CI failure is likely intermittent and will probably be resolved by https://github.com/AlecAivazis/survey/pull/404

mgabeler-lee-6rs commented 2 years ago

OK ... I don't seem to have permission to re-run the CI test to check that, but the tests do pass for me locally