On 14-May-2016, Ben Finney wrote: > I will attempt fixing this. This patch series alters the Bash command competion script for ‘debdiff(1)’, to allow matching filesystem entries and options as needed.
Bug#814570: Correct bash completion for debdiff. Ben Finney (4): Record the change being made in this branch. Special-case those options only allowed immediately after the command. Correct matching ‘--from’, ‘--to’, and package filenames. Correctly match filesystem entries for different options. debian/changelog | 2 ++ scripts/debdiff.bash_completion | 36 ++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 16 deletions(-) -- \ “A right is not what someone gives you; it's what no one can | `\ take from you.” —Ramsey Clark | _o__) | Ben Finney <b...@benfinney.id.au>
From 7430db434c12a6315ac3fc63e3cd143c7b026ba5 Mon Sep 17 00:00:00 2001 In-Reply-To: <20160514043456.ga17...@benfinney.id.au> References: <20160514043456.ga17...@benfinney.id.au> From: Ben Finney <b...@benfinney.id.au> Date: Sat, 14 May 2016 14:03:26 +1000 Subject: [PATCH 1/4] Record the change being made in this branch. --- debian/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index 92081fe0..9f8d24eb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,6 +43,8 @@ devscripts (2.17.7) UNRELEASED; urgency=medium [ Ben Finney ] * debdiff: + Code style improvements in Bash command completion script. + + Restructure Bash completion order. + (Closes: #814570) -- -- 2.11.0
From a08d5868782104436d99dafb52d7e0c0ab6a3327 Mon Sep 17 00:00:00 2001 In-Reply-To: <20160514043456.ga17...@benfinney.id.au> References: <20160514043456.ga17...@benfinney.id.au> From: Ben Finney <bign...@debian.org> Date: Fri, 7 Jul 2017 10:23:18 +1000 Subject: [PATCH 2/4] Special-case those options only allowed immediately after the command. --- scripts/debdiff.bash_completion | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/debdiff.bash_completion b/scripts/debdiff.bash_completion index 2a0a563c..d25abcd1 100644 --- a/scripts/debdiff.bash_completion +++ b/scripts/debdiff.bash_completion @@ -91,7 +91,9 @@ _debdiff () { case $file_list_mode in normal) - if [[ $cur == -* ]]; then + if [[ $prev == --debs-dir ]]; then + COMPREPLY=$( ( compgen -d -- "$cur" ) ) + elif [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) else declare -a _compreply=( $( compgen -o filenames -G '*.@(deb|dsc|changes)' ) ) -- 2.11.0
From 9b3a165294b33de470f8d90574db53989839efa4 Mon Sep 17 00:00:00 2001 In-Reply-To: <20160514043456.ga17...@benfinney.id.au> References: <20160514043456.ga17...@benfinney.id.au> From: Ben Finney <bign...@debian.org> Date: Fri, 7 Jul 2017 12:16:49 +1000 Subject: [PATCH 3/4] =?UTF-8?q?Correct=20matching=20=E2=80=98--from?= =?UTF-8?q?=E2=80=99,=20=E2=80=98--to=E2=80=99,=20and=20package=20filename?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/debdiff.bash_completion | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/debdiff.bash_completion b/scripts/debdiff.bash_completion index d25abcd1..381d8fd7 100644 --- a/scripts/debdiff.bash_completion +++ b/scripts/debdiff.bash_completion @@ -100,9 +100,12 @@ _debdiff () { COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) fi ;; - deb) + deb|from|to) declare -a _compreply=( $( compgen -o filenames -G '*.deb' ) ) COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) + if (( $move_from > 0 && $move_to < 0 )) ; then + COMPREPLY+=( $( compgen -W "--to" -- "$cur" ) ) + fi ;; dsc) declare -a _compreply=( $( compgen -o filenames -G '*.dsc' ) ) @@ -113,12 +116,6 @@ _debdiff () { COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) ;; *) - options=$(find . -name '*.deb' | sed -e's!\.\/!!' | paste -s -d' ') - if [[ $file_list_mode == from ]]; then - if (( $move_from > 0 )); then - options+=( --to ) - fi - fi COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) ;; esac -- 2.11.0
From 9986e8f9b1fbe22fd98b742d5f934229e2aa3483 Mon Sep 17 00:00:00 2001 In-Reply-To: <20160514043456.ga17...@benfinney.id.au> References: <20160514043456.ga17...@benfinney.id.au> From: Ben Finney <bign...@debian.org> Date: Fri, 7 Jul 2017 11:42:47 +1000 Subject: [PATCH 4/4] Correctly match filesystem entries for different options. --- scripts/debdiff.bash_completion | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/debdiff.bash_completion b/scripts/debdiff.bash_completion index 381d8fd7..12405684 100644 --- a/scripts/debdiff.bash_completion +++ b/scripts/debdiff.bash_completion @@ -92,28 +92,33 @@ _debdiff () { case $file_list_mode in normal) if [[ $prev == --debs-dir ]]; then - COMPREPLY=$( ( compgen -d -- "$cur" ) ) + COMPREPLY=( $( compgen -G "${cur}*" ) ) + compopt -o dirnames elif [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) else - declare -a _compreply=( $( compgen -o filenames -G '*.@(deb|dsc|changes)' ) ) - COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) + COMPREPLY=( $( compgen -G "${cur}*.@(deb|dsc|changes)" ) ) + compopt -o filenames + compopt -o plusdirs fi ;; deb|from|to) - declare -a _compreply=( $( compgen -o filenames -G '*.deb' ) ) - COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) + COMPREPLY=( $( compgen -G "${cur}*.deb" ) ) if (( $move_from > 0 && $move_to < 0 )) ; then COMPREPLY+=( $( compgen -W "--to" -- "$cur" ) ) fi + compopt -o filenames + compopt -o plusdirs ;; dsc) - declare -a _compreply=( $( compgen -o filenames -G '*.dsc' ) ) - COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) + COMPREPLY=( $( compgen -G "${cur}*.dsc" ) ) + compopt -o filenames + compopt -o plusdirs ;; changes) - declare -a _compreply=( $( compgen -o filenames -G '*.changes' ) ) - COMPREPLY=( $( compgen -W "${_compreply[*]}" -- "$cur" ) ) + COMPREPLY=( $( compgen -G "${cur}*.changes" ) ) + compopt -o filenames + compopt -o plusdirs ;; *) COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) -- 2.11.0
signature.asc
Description: PGP signature