From: Paul Wise <pabs@debian.org>
Subject: List held packages in dpkg
Origin: vendor, https://bugs.debian.org/907294
Bug-Debian: https://bugs.debian.org/907294
Forwarded: yes, https://github.com/scop/bash-completion/pull/250

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.

diff --git a/completions/dpkg b/completions/dpkg
index 681d48a1..f5b79103 100644
--- a/completions/dpkg
+++ b/completions/dpkg
@@ -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 @@ _comp_dpkg_installed_packages()
 _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()
