From 95647bc8ee6341c19a1e976d15b5a5855f2a1689 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 15 Jun 2019 07:23:06 +0000 Subject: [PATCH] In ask(): override default option if any of alwaysyes/alwaysno/rdonly is set. MFC after: 2 weeks --- sbin/fsck_msdosfs/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sbin/fsck_msdosfs/main.c b/sbin/fsck_msdosfs/main.c index 2b79cc02a201..6802afcefc46 100644 --- a/sbin/fsck_msdosfs/main.c +++ b/sbin/fsck_msdosfs/main.c @@ -129,9 +129,10 @@ ask(int def, const char *fmt, ...) char prompt[256]; int c; + if (alwaysyes || alwaysno || rdonly) + def = (alwaysyes && !rdonly && !alwaysno); + if (preen) { - if (rdonly) - def = 0; if (def) printf("FIXED\n"); return def; @@ -140,9 +141,9 @@ ask(int def, const char *fmt, ...) va_start(ap, fmt); vsnprintf(prompt, sizeof(prompt), fmt, ap); va_end(ap); - if (alwaysyes || rdonly) { - printf("%s? %s\n", prompt, rdonly ? "no" : "yes"); - return !rdonly; + if (alwaysyes || alwaysno || rdonly) { + printf("%s? %s\n", prompt, def ? "yes" : "no"); + return def; } do { printf("%s? [yn] ", prompt);