[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 9f49a101174911d8672c55cdc379ac5a3db186ff

Ville Skyttä ville.skytta at iki.fi
Sat Jan 9 10:57:59 UTC 2010


The following commit has been merged in the master branch:
commit 90736110f1344f2d6385a3e304debb13b084e4fd
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Jan 9 11:36:13 2010 +0200

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

diff --git a/contrib/rpm b/contrib/rpm
index 525da45..ca5fe31 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)

-- 
bash-completion



More information about the Bash-completion-commits mailing list