upgradepkg: Support oldpackage%newpackage notation.

This commit is contained in:
Igor Murzov 2011-11-17 04:02:35 +03:00
parent 068a1a1b53
commit 82784121d8
2 changed files with 24 additions and 0 deletions

View File

@ -11,6 +11,18 @@ _upgradepkg()
return 0
fi
if [[ "$cur" == ?*%* ]]; then
prev="${cur%%?(\\)%*}"
cur="${cur#*%}"
local nofiles IFS=$'\n'
compopt -o filenames
COMPREPLY=( $( compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur" ) )
[[ $COMPREPLY ]] || nofiles=1
COMPREPLY+=( $( compgen -P "$prev%" -S '/' -d -- "$cur" ) )
[[ $nofiles ]] && compopt -o nospace
return 0
fi
_filedir "t[bglx]z"
} && complete -F _upgradepkg upgradepkg

View File

@ -36,4 +36,16 @@ assert_complete_dir $files "upgradepkg " $dir $test
sync_after_int
set test "should complete *.t\[gbxl\]z files and dirs after % sign"
set oldpkg "xx-2.0-i486-2"
set dir $::srcdir/fixtures/slackware/home
set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \
\\( -type d -printf '$oldpkg%%%P/\\n' \\) -o \
\\( -type f -name '*.t\[bglx\]z' -printf '$oldpkg%%%P\\n' \\)"] "\n"]
assert_complete_dir $files "upgradepkg $oldpkg%" $dir $test
sync_after_int
teardown