PageRenderTime 55ms CodeModel.GetById 52ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion_lib/include/_rpm_installed_packages

http://github.com/brinkman83/bashrc
#! | 27 lines | 24 code | 3 blank | 0 comment | 0 complexity | 92db8a6f1be95b9fdd0e0063aeb56e64 MD5 | raw file
 1_rpm_installed_packages()
 2{
 3	local ver nodig nosig
 4
 5	if [ -r /var/log/rpmpkgs -a \
 6		/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
 7		# using RHL 7.2 or later - this is quicker than querying the DB
 8		COMPREPLY=( $( sed -ne \
 9		's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \
10				/var/log/rpmpkgs ) )
11	else
12		nodig=""
13		nosig=""
14		ver=$(rpm --version)
15		ver=${ver##* }
16	  
17		if [[ "$ver" > "4.0.4" ]]; then
18			nodig="--nodigest"
19		fi
20		if [[ "$ver" > "4.0.99" ]]; then
21			nosig="--nosignature"
22		fi
23
24		COMPREPLY=( $( rpm -qa $nodig $nosig | sed -ne \
25		's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) )
26	fi
27} # _rpm_installed_packages()