Whamcloud - gitweb
e2fsck: in ask_yn() fall back to English yes/no characters
authorTheodore Ts'o <tytso@mit.edu>
Tue, 22 Aug 2017 01:20:38 +0000 (21:20 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 22 Aug 2017 01:20:38 +0000 (21:20 -0400)
In the case of missing translations, if the translation for y/n is
missing due to fuzzy transactions, such that user is told to use
<y/n>, those characters will work correctly.

Addresses-Debian-Bug: #856586

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/util.c

index 87d320b..43cb7a7 100644 (file)
@@ -196,6 +196,9 @@ int ask_yn(e2fsck_t ctx, const char * string, int def)
        const char      *short_yes = _("yY");
        const char      *short_no = _("nN");
        const char      *short_yesall = _("aA");
+       const char      *english_yes = "yY";
+       const char      *english_no = "nN";
+       const char      *english_yesall = "aA";
        const char      *yesall_prompt = _(" ('a' enables 'yes' to all) ");
        const char      *extra_prompt = "";
        static int      yes_answers;
@@ -244,19 +247,28 @@ int ask_yn(e2fsck_t ctx, const char * string, int def)
                        return 0;
                }
                if (strchr(short_yes, (char) c)) {
+               do_yes:
                        def = 1;
                        if (yes_answers >= 0)
                                yes_answers++;
                        break;
                } else if (strchr(short_no, (char) c)) {
+               do_no:
                        def = 0;
                        yes_answers = -1;
                        break;
                } else if (strchr(short_yesall, (char)c)) {
+               do_all:
                        def = 2;
                        yes_answers = -1;
                        ctx->options |= E2F_OPT_YES;
                        break;
+               } else if (strchr(english_yes, (char) c)) {
+                       goto do_yes;
+               } else if (strchr(english_no, (char) c)) {
+                       goto do_no;
+               } else if (strchr(english_yesall, (char) c)) {
+                       goto do_all;
                } else if ((c == 27 || c == ' ' || c == '\n') && (def != -1)) {
                        yes_answers = -1;
                        break;