Treat EOF at whatnow prompt like 'x' instead of looping.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 16 Dec 1999 18:02:14 +0000 (18:02 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 16 Dec 1999 18:02:14 +0000 (18:02 +0000)
visudo.c

index f4bf564adcdb76f6727a193c6ee60bccc7d10632..8d51b7c15e18c804d5005e1ab4dae6f2610425d7 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -428,17 +428,21 @@ whatnow()
        for (c = choice; c != '\n' && c != EOF;)
            c = getchar();
 
-       if (choice == 'e' || choice == 'x' || choice == 'Q')
-           break;
-       else {
-           (void) puts("Options are:");
-           (void) puts("  (e)dit sudoers file again");
-           (void) puts("  e(x)it without saving changes to sudoers file");
-           (void) puts("  (Q)uit and save changes to sudoers file (DANGER!)\n");
+       switch (choice) {
+           case EOF:
+               choice = 'x';
+               /* FALLTHROUGH */
+           case 'e':
+           case 'x':
+           case 'Q':
+               return(choice);
+           default:
+               (void) puts("Options are:");
+               (void) puts("  (e)dit sudoers file again");
+               (void) puts("  e(x)it without saving changes to sudoers file");
+               (void) puts("  (Q)uit and save changes to sudoers file (DANGER!)\n");
        }
     }
-
-    return(choice);
 }
 
 /*