Skip to content

Commit 21d1c64

Browse files
committed
refactor(upgradepkg): use _comp_compgen -P for *%*
1 parent 54b0fa2 commit 21d1c64

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

completions/upgradepkg

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ _comp_cmd_upgradepkg()
1010
return
1111
fi
1212

13-
if [[ $cur == ?*%* ]]; then
14-
prev="${cur%%?(\\)%*}"
15-
cur="${cur#*%}"
16-
local nofiles=""
13+
if [[ $cur =~ ^[^%]+% ]]; then
14+
local prefix=$BASH_REMATCH nofiles=""
1715
compopt -o filenames
18-
_comp_compgen -- -P "$prev%" -f -X "!*.t[bgxl]z" || nofiles=set
19-
_comp_compgen -a -- -P "$prev%" -S '/' -d
16+
_comp_compgen -P "$prefix" -- -f -X "!*.t[bgxl]z" || nofiles=set
17+
_comp_compgen -aP "$prefix" -- -S '/' -d
2018
[[ $nofiles ]] && compopt -o nospace
2119
return
2220
fi

0 commit comments

Comments
 (0)