sbin/fsck_msdosfs: Bring in freebsd/freebsd@95647bc8 (fix ask())
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 14 Sep 2019 17:53:30 +0000 (02:53 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 14 Sep 2019 18:18:14 +0000 (03:18 +0900)
sbin/fsck_msdosfs/main.c

index d9528b9..dc81322 100644 (file)
@@ -119,9 +119,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;
@@ -129,9 +130,9 @@ ask(int def, const char *fmt, ...)
 
        va_start(ap, fmt);
        vsnprintf(prompt, sizeof(prompt), fmt, 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);