summaryrefslogtreecommitdiff
path: root/contrib/rpm
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2010-01-09 11:36:13 +0200
committerVille Skyttä <ville.skytta@iki.fi>2010-01-09 11:36:13 +0200
commit90736110f1344f2d6385a3e304debb13b084e4fd (patch)
treecd1a5aee5860204645388066234883ca5acb7629 /contrib/rpm
parent89affc872b1f345e26a24f7debb95c843ff44fae (diff)
downloadbash-completion-90736110f1344f2d6385a3e304debb13b084e4fd.tar.gz
Protect rpm installed packages and --eval from sed metacharacters in input.
Diffstat (limited to 'contrib/rpm')
-rw-r--r--contrib/rpm12
1 files changed, 6 insertions, 6 deletions
diff --git a/contrib/rpm b/contrib/rpm
index 525da459..ca5fe311 100644
--- a/contrib/rpm
+++ b/contrib/rpm
@@ -10,9 +10,9 @@ _rpm_installed_packages()
if [[ -r /var/log/rpmpkgs && \
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
# using RHL 7.2 or later - this is quicker than querying the DB
- COMPREPLY=( $( sed -ne \
- 's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
- /var/log/rpmpkgs ) )
+ COMPREPLY=( $( compgen -W "$( sed -ne \
+ 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
+ /var/log/rpmpkgs )" -- "$cur" ) )
elif type rpmqpack &>/dev/null ; then
# SUSE's rpmqpack is faster than rpm -qa
COMPREPLY=( $( compgen -W '$( rpmqpack )' -- "$cur" ) )
@@ -96,9 +96,9 @@ _rpm()
;;
--eval|-E)
# get a list of macros
- COMPREPLY=( $( rpm --showrc | sed -ne \
- 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\('${cur#%}'[^[:space:](]*\).*/\1/p' ) )
- COMPREPLY=( "${COMPREPLY[@]/#/%}" )
+ COMPREPLY=( $( compgen -W "$( rpm --showrc | sed -ne \
+ 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" \
+ -- "$cur" ) )
return 0
;;
--pipe)