mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
notmuch setup: Exit if EOF is encountered at any prompt.
If the user is explicitly providing EOF, then terminating the program is the most likely desired thing to do. This also avoids undefined behavior from continuing with an uninitialized response after ignoring the return value of getline().
This commit is contained in:
parent
5f0b2ece16
commit
eb0cf86c7a
1 changed files with 9 additions and 6 deletions
|
@ -100,12 +100,15 @@ notmuch_setup_command (unused (void *ctx),
|
|||
unsigned int i;
|
||||
int is_new;
|
||||
|
||||
#define prompt(format, ...) \
|
||||
do { \
|
||||
printf (format, ##__VA_ARGS__); \
|
||||
fflush (stdout); \
|
||||
getline (&response, &response_size, stdin); \
|
||||
chomp_newline (response); \
|
||||
#define prompt(format, ...) \
|
||||
do { \
|
||||
printf (format, ##__VA_ARGS__); \
|
||||
fflush (stdout); \
|
||||
if (getline (&response, &response_size, stdin) < 0) { \
|
||||
printf ("Exiting.\n"); \
|
||||
exit (1); \
|
||||
} \
|
||||
chomp_newline (response); \
|
||||
} while (0)
|
||||
|
||||
config = notmuch_config_open (ctx, NULL, &is_new);
|
||||
|
|
Loading…
Reference in a new issue