archlinux-downgrade / downgrade

Downgrade packages in Arch Linux
GNU General Public License v2.0
570 stars 24 forks source link

Ability to add a package to ignored regardless of the keyboard layout #219

Open TAforever opened 12 months ago

TAforever commented 12 months ago

Hello! Could you make it so that when I downgrade a package, when asked whether to add the package to those ignored during the upgrade, the confirmation is accepted regardless of the keyboard layout, as many other programs work. The fact is that I have a Russian layout and it is not convenient to switch the layout to add a package to the ignored ones. The program will add the package to the ignored ones only with the Russian keyboard layout Д/н if I press Y/n then nothing will happen.

pbrisbin commented 12 months ago

Oh, interesting use-case!

Looking over the code, I find this:

        eval_gettext "add \$pkg to IgnorePkg? [y/N] "
        read -r ans
        if [[ "${ans,,}" == $(gettext 'y')* ]]; then

What that means is that we compare ans with the localized string for y. With the ru locale, which I assume you're using, that is:

#: bin/downgrade:129
msgid "y"
msgstr "д"

So gettext 'y' returns д. If you enter that (ans="д"), then the condition's true and it works. If you type y instead (ans="y"), the condition's false and it doesn't work.

It sounds like your use-case is to be in one locale (ru), but answer prompts in another (en). This isn't directly related to keyboard layout, but I can see how one leads to the other. Just curious, is there a reason you don't switch locales when you switch keyboard layouts?

The only way I can think of to make this work is if we change our code to also accept en answers to prompts in addition to the localized values.

Does this all sound accurate? Am I missing anything?

TAforever commented 12 months ago

Yes, thank you, you understood everything correctly. I’m just too lazy to switch the layout because when working in the shell, the Russian layout is almost never needed.

pbrisbin commented 12 months ago

OK, it shouldn't be much trouble to implement,

-        if [[ "${ans,,}" == $(gettext 'y')* ]]; then
-          pacignore add -c "$PACMAN_CONF" "$pkg"
-        fi
+        case "${ans,,}" in
+          # comment explaining why we're doing this surprising thing
+          $(gettext 'y')*|y*)
+            pacignore add -c "$PACMAN_CONF" "$pkg"
+          ;;
+        esac

(And similar anywhere else we have a y/n prompt.)

I'm not sure when I'd be able to actually do this work/release, etc, but I'll leave this here in case anyone else can jump on it.