Package: bash-completion
Version: 1:2.8-1
Severity: normal
File: /usr/share/bash-completion/completions/dpkg
Tags: patch

The completion for dpkg -L/--listfiles does not list held packages when
grep-status (from dctrl-tools) is installed. This is because the
grep-status _comp_dpkg_purgeable_packages cares about the dpkg package
selection states (install/hold/deinstall/purge) while the other version
only cares about the dpkg package states (installed/unpacked/etc).

There is a similar issue for the _comp_dpkg_installed_packages function.

The fix for this is quite simple, just remove install/deinstall from
the arguments to the -FStatus options.

$ dpkg --get-selections | grep ^una
unace                                           install
unar                                            install
unattended-upgrades                             hold

$ dpkg --listfiles una
unace  unar   

$ dpkg -L una
unace  unar   

$ grep -A1 listfiles /usr/share/bash-completion/completions/dpkg
        -L|-P|--listfiles|--purge)
            COMPREPLY=( $( _comp_dpkg_purgeable_packages "$cur" ) )

$ grep -B1 -A8 ^_comp_dpkg_purgeable_packages 
/usr/share/bash-completion/completions/dpkg
_have grep-status && {
_comp_dpkg_purgeable_packages()
{
    grep-status -P -e "^$1" -a -FStatus 'install ok installed' -o -FStatus 
'deinstall ok config-files' -n -s Package
}
} || {
_comp_dpkg_purgeable_packages()
{
    command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \
        command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
            half-configured|config-files" \
            -Ee "^Essential: yes" | \
        awk "/Package: $1/ { print \$2 }" 2>/dev/null
}
}

$ diff -u /usr/share/bash-completion/completions/dpkg*
--- /usr/share/bash-completion/completions/dpkg 2018-03-31 07:07:32.000000000 
+0800
+++ /usr/share/bash-completion/completions/dpkg.fixed   2018-08-26 
12:02:49.488857999 +0800
@@ -3,7 +3,7 @@
 _have grep-status && {
 _comp_dpkg_installed_packages()
 {
-    grep-status -P -e "^$1" -a -FStatus 'install ok installed' -n -s Package
+    grep-status -P -e "^$1" -a -FStatus 'ok installed' -n -s Package
 }
 } || {
 _comp_dpkg_installed_packages()
@@ -19,7 +19,7 @@
 _have grep-status && {
 _comp_dpkg_purgeable_packages()
 {
-    grep-status -P -e "^$1" -a -FStatus 'install ok installed' -o -FStatus 
'deinstall ok config-files' -n -s Package
+    grep-status -P -e "^$1" -a -FStatus 'ok installed' -o -FStatus 'ok 
config-files' -n -s Package
 }
 } || {
 _comp_dpkg_purgeable_packages()

-- System Information:
Debian Release: buster/sid
  APT prefers testing-debug
  APT policy: (900, 'testing-debug'), (900, 'testing'), (800, 
'unstable-debug'), (800, 'unstable'), (790, 'buildd-unstable'), (700, 
'experimental-debug'), (700, 'experimental'), (690, 'buildd-experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.17.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8), 
LANGUAGE=en_AU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

-- no debconf information

-- 
bye,
pabs

https://wiki.debian.org/PaulWise

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to