[pacman-dev] [PATCH 1/1] always accept untranslated answers 'Y' and 'N'
From: Christian Hesse <mail@eworm.de> 'YES' translates to 'JA' in German, thus answer 'J' is expected for positive answer. This changes the behaviour to always accept 'Y' and 'N', in addition to the translated values. Signed-off-by: Christian Hesse <mail@eworm.de> --- src/pacman/util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index fd7438b..e878cb3 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1587,9 +1587,13 @@ static int question(short preset, const char *format, va_list args) fprintf(stream, "%s\n", response); } - if(mbscasecmp(response, _("Y")) == 0 || mbscasecmp(response, _("YES")) == 0) { + if(mbscasecmp(response, "Y") == 0 /* always accept untranslated */ + || mbscasecmp(response, _("Y")) == 0 + || mbscasecmp(response, _("YES")) == 0) { return 1; - } else if(mbscasecmp(response, _("N")) == 0 || mbscasecmp(response, _("NO")) == 0) { + } else if(mbscasecmp(response, "N") == 0 /* always accept untranslated */ + || mbscasecmp(response, _("N")) == 0 + || mbscasecmp(response, _("NO")) == 0) { return 0; } } -- 2.10.2
On Fri, 11 Nov 2016 at 21:15:48, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
'YES' translates to 'JA' in German, thus answer 'J' is expected for positive answer. This changes the behaviour to always accept 'Y' and 'N', in addition to the translated values.
Signed-off-by: Christian Hesse <mail@eworm.de> --- src/pacman/util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c index fd7438b..e878cb3 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1587,9 +1587,13 @@ static int question(short preset, const char *format, va_list args) fprintf(stream, "%s\n", response); }
- if(mbscasecmp(response, _("Y")) == 0 || mbscasecmp(response, _("YES")) == 0) { + if(mbscasecmp(response, "Y") == 0 /* always accept untranslated */ + || mbscasecmp(response, _("Y")) == 0 + || mbscasecmp(response, _("YES")) == 0) { return 1; - } else if(mbscasecmp(response, _("N")) == 0 || mbscasecmp(response, _("NO")) == 0) { + } else if(mbscasecmp(response, "N") == 0 /* always accept untranslated */ + || mbscasecmp(response, _("N")) == 0 + || mbscasecmp(response, _("NO")) == 0) {
Not sure whether it is a problem in practice but what happens if "N" is translated to "Y" in some language? Do we really want to accept if the user enters "Y" in that case?
return 0; } } -- 2.10.2
Lukas Fleischer <lfleischer@archlinux.org> on Fri, 2016/11/11 21:23:
On Fri, 11 Nov 2016 at 21:15:48, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
'YES' translates to 'JA' in German, thus answer 'J' is expected for positive answer. This changes the behaviour to always accept 'Y' and 'N', in addition to the translated values.
Not sure whether it is a problem in practice but what happens if "N" is translated to "Y" in some language? Do we really want to accept if the user enters "Y" in that case?
A valid point... Does such a language exist? All my systems are configured with English locale, except my wife's and my mother's one. My blind typing for pacman commands breaks there. :-p Well, possibly I should just set the root account to English locale... :D -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
On Fri, Nov 11, 2016 at 09:34:05PM +0100, Christian Hesse wrote:
Lukas Fleischer <lfleischer@archlinux.org> on Fri, 2016/11/11 21:23:
On Fri, 11 Nov 2016 at 21:15:48, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
'YES' translates to 'JA' in German, thus answer 'J' is expected for positive answer. This changes the behaviour to always accept 'Y' and 'N', in addition to the translated values.
Not sure whether it is a problem in practice but what happens if "N" is translated to "Y" in some language? Do we really want to accept if the user enters "Y" in that case?
A valid point... Does such a language exist?
It does! Looks like Uzbek would break if we did this: src/pacman/po/uz.po:msgid "No" src/pacman/po/uz.po-msgstr "Yo'q"
All my systems are configured with English locale, except my wife's and my mother's one. My blind typing for pacman commands breaks there. :-p
Well, possibly I should just set the root account to English locale... :D -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
"Yes" in Swahili it is "Ndiyo", in Arabic it's "Na'am", Greek is "Nai", ... apt on Ubuntu allows to answer with "J" for "Yes" on a German locale. But I am not sure if apt unconditionally allows to answer with "Y/N". In general I think it's a bad idea. Either allow localized input only, or Y/N only. On 11/11/16 21:34, Christian Hesse wrote:
Lukas Fleischer <lfleischer@archlinux.org> on Fri, 2016/11/11 21:23:
On Fri, 11 Nov 2016 at 21:15:48, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
'YES' translates to 'JA' in German, thus answer 'J' is expected for positive answer. This changes the behaviour to always accept 'Y' and 'N', in addition to the translated values.
Not sure whether it is a problem in practice but what happens if "N" is translated to "Y" in some language? Do we really want to accept if the user enters "Y" in that case?
A valid point... Does such a language exist?
All my systems are configured with English locale, except my wife's and my mother's one. My blind typing for pacman commands breaks there. :-p
Well, possibly I should just set the root account to English locale... :D
Christian Hesse <list@eworm.de> on Fri, 2016/11/11 21:34:
Lukas Fleischer <lfleischer@archlinux.org> on Fri, 2016/11/11 21:23:
On Fri, 11 Nov 2016 at 21:15:48, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
'YES' translates to 'JA' in German, thus answer 'J' is expected for positive answer. This changes the behaviour to always accept 'Y' and 'N', in addition to the translated values.
Not sure whether it is a problem in practice but what happens if "N" is translated to "Y" in some language? Do we really want to accept if the user enters "Y" in that case?
A valid point... Does such a language exist?
Answering myself... Yes! So we definitely do *not* want this. Nevertheless... Learned some interesting facts about languages. :D -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
participants (4)
-
Christian Hesse
-
Dave Reisner
-
Florian Weigelt
-
Lukas Fleischer