bash-completion: use POSIX character classes in regular expressions

bash uses POSIX extended regular expressions via regex(3), which does
not guarantee support for shorthand character classes. Although glibc
supports it, msys2-runtime does not.

Make sure the completion script works (hopefully) everywhere by being
more portable.

Fixes: https://github.com/msys2/MSYS2-packages/pull/1549

Original-patch-by: plotasse <platos@protonmail.ch>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Eli Schwartz 2019-06-25 17:20:06 -04:00 committed by Allan McRae
parent d917109432
commit cd475331f4

View file

@ -24,7 +24,7 @@ _arch_ptr2comp() {
} }
_arch_incomp() { _arch_incomp() {
local r="\s-(-${1#* }\s|\w*${1% *})"; [[ $COMP_LINE =~ $r ]] local r="[[:space:]]-(-${1#* }[[:space:]]|[[:alnum:]_]*${1% *})"; [[ $COMP_LINE =~ $r ]]
} }
_pacman_keyids() { _pacman_keyids() {
@ -77,7 +77,7 @@ _makepkg() {
_init_completion || return _init_completion || return
if [[ $prev = @(-p|--config) ]]; then if [[ $prev = @(-p|--config) ]]; then
compopt -o default compopt -o default
elif [[ ! $prev =~ ^-(-(config|help|key|version)$|\w*[Vh]) ]]; then elif [[ ! $prev =~ ^-(-(config|help|key|version)$|[[:alnum:]_]*[Vh]) ]]; then
opts=('allsource asdeps check clean cleanbuild config force geninteg help opts=('allsource asdeps check clean cleanbuild config force geninteg help
holdver ignorearch install key log needed noarchive nobuild nocheck holdver ignorearch install key log needed noarchive nobuild nocheck
nocolor noconfirm nodeps noextract noprepare noprogressbar nosign nocolor noconfirm nodeps noextract noprepare noprogressbar nosign
@ -127,7 +127,7 @@ _pacman() {
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
_arch_ptr2comp core _arch_ptr2comp core
elif [[ ! $prev =~ ^-\w*[Vbhr] && elif [[ ! $prev =~ ^-[[:alnum:]_]*[Vbhr] &&
! $prev = --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|logfile|root|version) ]] ! $prev = --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|logfile|root|version) ]]
then then
[[ $cur = -* ]] && _arch_ptr2comp ${o#* } common || [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||