FS#67808 - bash completion breaks with nocaseglob

Attached to Project: Pacman
Opened by Alexandre Bouvier (doskoi) - Wednesday, 02 September 2020, 16:37 GMT
Last edited by Eli Schwartz (eschwartz) - Monday, 05 April 2021, 23:32 GMT
Task Type Bug Report
Category Scripts & Tools
Status Closed
Assigned To Eli Schwartz (eschwartz)
Architecture All
Severity Low
Priority Normal
Reported Version 5.2.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

Setting the nocaseglob shell option in bash (in ~/.bashrc or directly in the shell) breaks pacman completion for some commands like "-S" or "-R", but not "-Q".
Maybe the option should be explicitly disabled in the completion script (and his state saved/restored before returning).


Additional info:

bash 5.0.018-1
bash-completion 2.11-1
pacman 5.2.2-1


Steps to reproduce:

$ pacman -S xx<TAB>
xxhash xxkb
$ pacman -Q arch<TAB>
arch-audit arch-install-scripts archlinux-keyring
$ shopt -s nocaseglob
$ pacman -S xx<TAB>
$ pacman -Q arch<TAB>
arch-audit arch-install-scripts archlinux-keyring

This task depends upon

Closed by  Eli Schwartz (eschwartz)
Monday, 05 April 2021, 23:32 GMT
Reason for closing:  Upstream
Additional comments about closing:  bug is in bash < 5.1
Comment by Alexandre Bouvier (doskoi) - Wednesday, 02 September 2020, 16:59 GMT Comment by Eli Schwartz (eschwartz) - Wednesday, 02 September 2020, 18:12 GMT
One example of the breakage is:

> elif [[ ! $prev =~ ^-[[:alnum:]_]*[Vbhr] &&

This is broken by nocaseglob causing erroneous matches for -v, -B, -H, -R of which -R is relevant.

Generally, our shell completions use regular expression matching. Why is this even getting tripped up by nocaseglob which is specific to *files*? Very confusing...

Ah: https://stackoverflow.com/questions/62397088/bash-regex-match-is-case-insensitive/62435670#62435670
https://git.savannah.gnu.org/cgit/bash.git/diff/?id=aa99ef520f943369c826b02f3398fa8eab7bfdfb

Should be fixed in bash's devel branch. It's quite purely just a bug in bash. I'm inclined to think nocaseglob is simply too broken to use until then, because there's way too many ramifications for regexp here. Quite possibly, we're broken "literally everywhere".
Comment by Eli Schwartz (eschwartz) - Thursday, 17 December 2020, 20:14 GMT
Now that bash 5.1 is shipped on Arch, this is no longer reproducible.
Comment by Alexandre Bouvier (doskoi) - Friday, 18 December 2020, 09:08 GMT
Yes, everything works as expected now ;)

Loading...