Slight refactoring: Make dglob more readable
Gbp-Dch: Ignore
Axel Beckert
6 years ago
19 | 19 | # 02111-1307, USA. |
20 | 20 | # |
21 | 21 | |
22 | ARGS=`getopt -o af0reinXv -n dglob -- "$@"` | |
22 | ARGS=$(getopt -o af0reinXv -n dglob -- "$@") | |
23 | 23 | eval set -- "$ARGS" |
24 | 24 | |
25 | 25 | |
35 | 35 | |
36 | 36 | while true; do |
37 | 37 | case "$1" in |
38 | -n) shift; ARGS=`echo $@ | sed -e 's/--/ /'`; dglob_not $ARGS; exit 0;; | |
38 | -n) shift; ARGS=$(echo $@ | sed -e 's/--/ /'); dglob_not $ARGS; exit 0;; | |
39 | 39 | -a) filter="cat" ; all="yes" ; shift ;; |
40 | 40 | -0) SEP=0 ; shift ;; |
41 | 41 | -r|-e|-i|-X|-v) grep_dctrl_options="$grep_dctrl_options $1"; shift ;; |
42 | 42 | -f) expand="xargs dpkg --listfiles | perl -nl${SEP}e 'print if -f'" |
43 | 43 | if [ "$all" = "yes" ] ; then |
44 | if [ -n "`which apt-file`" ] ; then | |
44 | if [ -n "$(which apt-file)" ] ; then | |
45 | 45 | # if we have apt-file use it instead |
46 | 46 | expand="while read pack; do apt-file show \$pack; done | perl -ple 's/^.*?: //'" |
47 | 47 | else |
59 | 59 | |
60 | 60 | # Does the package exist? |
61 | 61 | if [ "$all" = "no" ] ; then |
62 | packages=`eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1"` | |
62 | packages=$(eval $filter /var/lib/dpkg/status | \ | |
63 | grep-dctrl -PnsPackage $grep_dctrl_options "$1") | |
63 | 64 | if [ -z "$packages" ] ; then |
64 | 65 | exit 1 |
65 | 66 | fi |
66 | eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1" | grep -v ^$ | | |
67 | (eval $expand) | |
67 | eval $filter /var/lib/dpkg/status | \ | |
68 | grep-dctrl -PnsPackage $grep_dctrl_options "$1" | \ | |
69 | grep -v ^$ | \ | |
70 | (eval $expand) | |
68 | 71 | else |
69 | 72 | # Use grep-available as the status file does not include all available |
70 | 73 | # packages |
71 | grep-aptavail -PnsPackage $grep_dctrl_options "$1" | grep -v ^$ | | |
72 | (eval $expand) | |
74 | grep-aptavail -PnsPackage $grep_dctrl_options "$1" | \ | |
75 | grep -v ^$ | \ | |
76 | (eval $expand) | |
73 | 77 | fi |