From b710439d328f7fab3f75f01733c0a5704995c328 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 25 Jul 2022 04:23:38 -0700 Subject: 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. --- src/setup.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/setup.c') 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); } -- cgit v1.2.1