Protect rpm installed packages and --eval from sed metacharacters in input.

This commit is contained in:
Ville Skyttä 2010-01-09 11:36:13 +02:00
parent 89affc872b
commit 90736110f1

View File

@ -10,9 +10,9 @@ _rpm_installed_packages()
if [[ -r /var/log/rpmpkgs && \ if [[ -r /var/log/rpmpkgs && \
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
# using RHL 7.2 or later - this is quicker than querying the DB # using RHL 7.2 or later - this is quicker than querying the DB
COMPREPLY=( $( sed -ne \ COMPREPLY=( $( compgen -W "$( sed -ne \
's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \ 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
/var/log/rpmpkgs ) ) /var/log/rpmpkgs )" -- "$cur" ) )
elif type rpmqpack &>/dev/null ; then elif type rpmqpack &>/dev/null ; then
# SUSE's rpmqpack is faster than rpm -qa # SUSE's rpmqpack is faster than rpm -qa
COMPREPLY=( $( compgen -W '$( rpmqpack )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( rpmqpack )' -- "$cur" ) )
@ -96,9 +96,9 @@ _rpm()
;; ;;
--eval|-E) --eval|-E)
# get a list of macros # get a list of macros
COMPREPLY=( $( rpm --showrc | sed -ne \ COMPREPLY=( $( compgen -W "$( rpm --showrc | sed -ne \
's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\('${cur#%}'[^[:space:](]*\).*/\1/p' ) ) 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" \
COMPREPLY=( "${COMPREPLY[@]/#/%}" ) -- "$cur" ) )
return 0 return 0
;; ;;
--pipe) --pipe)