diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-07-25 04:23:38 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-07-27 08:36:24 -0700 |
commit | b710439d328f7fab3f75f01733c0a5704995c328 (patch) | |
tree | b766c317d7e0cb663cc25a3d85eb76e69cacb7cf /src | |
parent | e9e86a017d0a0e5857b9f2c9ecf29b3bdc0ae26a (diff) |
setup: don't spin on EOF in setup_interactively()
If you hit ^D during interactive setup it'd send things
infinitely spinning.
This commit treats eof when expecting more input as -EIO and
simply gives up. Which I imagine technically means it's possible
to terminate the last interactive question with EOF/^D instead of
newline and have it work, since we only check it before the
fgets() used to get more input.
Diffstat (limited to 'src')
-rw-r--r-- | src/setup.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/setup.c b/src/setup.c index e4c22f3..6b8677f 100644 --- a/src/setup.c +++ b/src/setup.c @@ -98,6 +98,10 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings if (!defaults) { fflush(stdout); + + if (feof(stdin)) + return -EIO; + fgets(buf, sizeof(buf), stdin); } |