Match uppercased versions of _filedir and _filedir_xspec arguments too.
This provides a bit of case insensivity to file extension matching, allowing for example _filedir foo to match both *.foo and *.FOO. Note that this is not real case insensivity; mixed case extensions like *.FOO.gz are not matched by _filedir foo.gz so those need to be handled like before this change.
This commit is contained in:
parent
d0bcb5347e
commit
c183a585b2
2
CHANGES
2
CHANGES
@ -20,6 +20,8 @@ bash-completion (2.x)
|
||||
--all long options (RedHat: #630328).
|
||||
* Improve rpm query option completions.
|
||||
* Drop bad kompare filename completion (Alioth: #312708).
|
||||
* Make _filedir and _filedir_xspec complete uppercase versions of their
|
||||
filename extension arguments in addition to exact case matches.
|
||||
|
||||
[ Freddy Vulto ]
|
||||
* Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)
|
||||
|
@ -610,7 +610,8 @@ _quote_readline_by_ref()
|
||||
# This function performs file and directory completion. It's better than
|
||||
# simply using 'compgen -f', because it honours spaces in filenames.
|
||||
# @param $1 If `-d', complete only on directories. Otherwise filter/pick only
|
||||
# completions with `.$1' as file extension.
|
||||
# completions with `.$1' and the uppercase version of it as file
|
||||
# extension.
|
||||
#
|
||||
_filedir()
|
||||
{
|
||||
@ -636,7 +637,10 @@ _filedir()
|
||||
))
|
||||
|
||||
if [[ "$1" != -d ]]; then
|
||||
xspec=${1:+"!*.$1"}
|
||||
# Munge xspec to contain uppercase version too
|
||||
[[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
|
||||
xspec=${1:+"!*.@($1|${1^^})"} || \
|
||||
xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
|
||||
toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
|
||||
if [ ${#toks[@]} -ne 0 ]; then
|
||||
# If `compopt' is available, set `-o filenames'
|
||||
@ -1586,8 +1590,19 @@ _filedir_xspec()
|
||||
}
|
||||
))
|
||||
|
||||
# Munge xspec to contain uppercase version too
|
||||
eval xspec="${xspec}"
|
||||
local matchop=!
|
||||
if [[ $xspec == !* ]]; then
|
||||
xspec=${xspec#!}
|
||||
matchop=@
|
||||
fi
|
||||
[[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
|
||||
xspec="$matchop($xspec|${xspec^^})" || \
|
||||
xspec="$matchop($xspec|$(printf %s $xspec | tr '[:lower:]' '[:upper:]'))"
|
||||
|
||||
toks=( ${toks[@]-} $(
|
||||
eval compgen -f -X "$xspec" -- "\$(quote_readline "\$cur")" | {
|
||||
eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
|
||||
while read -r tmp; do
|
||||
[ -n $tmp ] && printf '%s\n' $tmp
|
||||
done
|
||||
|
0
test/fixtures/_filedir/ext/ii.E1
vendored
Normal file
0
test/fixtures/_filedir/ext/ii.E1
vendored
Normal file
@ -242,7 +242,7 @@ foreach name {f f2} {
|
||||
|
||||
|
||||
set test "completing with filter '.e1' should show completions"
|
||||
assert_complete_dir {ee.e1 foo/ gg.e1} "g " "fixtures/_filedir/ext" $test
|
||||
assert_complete_dir {ee.e1 foo/ gg.e1 ii.E1} "g " "fixtures/_filedir/ext" $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
Loading…
x
Reference in New Issue
Block a user