]> sourceware.org Git - lvm2.git/commitdiff
Move y/n prompts to stderr and repeat if response has both 'n' and 'y'.
authorAlasdair Kergon <agk@redhat.com>
Wed, 23 Nov 2011 01:34:38 +0000 (01:34 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 23 Nov 2011 01:34:38 +0000 (01:34 +0000)
(Note that in a future release we might make this stricter and insist
on exactly 'y' or 'n'.)

WHATS_NEW
lib/display/display.c

index 1551ebcbbf228e782198ce85305c26dda7b07de8..d0540fb90252334e5ebab6768cd81c00e9f6a5cb 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Move y/n prompts to stderr and repeat if response has both 'n' and 'y'.
   Replace the unit testing framework with CUnit (--enable-testing).
   Fix dmeventd snapshot monitoring when multiple extensions were involved.
   Don't ignore configure --mandir and --infodir.
index 6e61dc8271db092db33906c2c8e9aaf4592c4ddd..298abc9501c426a6d97fb6f8b011348af3975484 100644 (file)
@@ -850,9 +850,10 @@ char yes_no_prompt(const char *prompt, ...)
        do {
                if (c == '\n' || !c) {
                        va_start(ap, prompt);
-                       vprintf(prompt, ap);
+                       vfprintf(stderr, prompt, ap);
                        va_end(ap);
-                       fflush(stdout);
+                       fflush(stderr);
+                       ret = 0;
                }
 
                if ((c = getchar()) == EOF) {
@@ -861,9 +862,14 @@ char yes_no_prompt(const char *prompt, ...)
                }
 
                c = tolower(c);
-               if ((c == 'y') || (c == 'n'))
-                       ret = c;
-       } while (!ret || c != '\n');
+               if ((c == 'y') || (c == 'n')) {
+                       /* If both 'y' and 'n' given, begin again. */
+                       if (ret && c != ret)
+                               ret = -1;
+                       else
+                               ret = c;
+               }
+       } while (ret < 1 || c != '\n');
 
        sigint_restore();
 
This page took 0.041684 seconds and 5 git commands to generate.