Package: bash-completion
Version: 1:2.0-1
Severity: normal
Tags: patch

Dear Maintainer,

the bash completion for dpkg-deb with options -R, --raw-extract or
--vextract does not work. The handling for these options is missing
in /usr/share/bash-completion/completions/dpkg.

The attached patch works for me, but it's not extensively tested.
I had to split the function for dpkg and dpkg-deb as the usage of
parameter -R of dpkg and dpkg-deb is not compatible.

Regards

Uwe


PS: Is there a guideline in which order program options should be
    listed to ease maintenance? As they are not in alphabetical
    order I have used the order from 'dpkg-deb --help' as the 2nd
    best guess.


-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (750, 'testing'), (650, 'unstable'), (1, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages bash-completion depends on:
ii  bash  4.2+dfsg-0.1
ii  dpkg  1.16.9

bash-completion recommends no packages.

bash-completion suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/bash-completion/completions/dpkg (from 
bash-completion package)
--- usr/share/bash-completion/completions/dpkg.orig	2012-06-17 21:09:06.000000000 +0200
+++ usr/share/bash-completion/completions/dpkg	2013-01-25 23:40:35.710070458 +0100
@@ -32,7 +32,7 @@
 }
 }
 
-# Debian dpkg(8) completion
+# Debian dpkg(1) completion
 #
 _dpkg()
 {
@@ -54,7 +54,7 @@
     case $prev in
         -c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \
         --contents|--info|--fsys-tarfile|--field|--control|--extract| \
-        --show)
+        --vextract|--show)
             _filedir '?(u)deb'
             return 0
             ;;
@@ -85,7 +85,45 @@
     COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     [[ $COMPREPLY == *= ]] && compopt -o nospace
 } &&
-complete -F _dpkg dpkg dpkg-deb dpkg-query
+complete -F _dpkg dpkg dpkg-query
+
+# Debian dpkg-deb(1) completion
+#
+_dpkg_deb()
+{
+    local cur prev words cword split
+    _init_completion -s || return
+
+    _expand || return 0
+
+    local i=$cword
+
+    # find the last option flag
+    if [[ $cur != -* ]]; then
+        while [[ $prev != -* && $i -ne 1 ]]; do
+            i=$((i-1))
+            prev=${words[i-1]}
+        done
+    fi
+
+    case $prev in
+        -c|-I|-W|-f|-e|-x|-X|-R|--contents|--info|--show|--field|--control| \
+        --extract|--vextract|--raw-extract|--fsys-tarfile)
+            _filedir '?(u)deb'
+            return 0
+            ;;
+        -b|--build)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return
+
+    COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+    [[ $COMPREPLY == *= ]] && compopt -o nospace
+} &&
+complete -F _dpkg_deb dpkg-deb
 
 # Debian GNU dpkg-reconfigure(8) completion
 #

Reply via email to