From 3531748071ead7740ab1492d6e422cd3f4fae951 Mon Sep 17 00:00:00 2001 From: Maarten Bezemer Date: Wed, 22 Feb 2012 10:09:28 +0100 Subject: Bug#660838: pbuilder: Add complete bash_autocompletion for all flags and arguments Package: pbuilder Version: 0.206 Severity: normal Tags: patch Currently, pbuidler only supports bash_completion for the commands (first argument) and filename completion for the .dsc file. This patch adds additional support for all flags and filename/directory completion for flags that require this. The patch is submitted (and accepted) to Ubuntu in two phases, see these bug reports: - https://bugs.launchpad.net/ubuntu/+source/pbuilder/+bug/770529 - https://bugs.launchpad.net/ubuntu/+source/pbuilder/+bug/933339 Please consider to apply this patch. Thanks in advance, Maarten *** bash_completion.debdiff --- bash_completion.d/pbuilder | 70 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 9 deletions(-) (limited to 'bash_completion.d') diff --git a/bash_completion.d/pbuilder b/bash_completion.d/pbuilder index 1338411..2dd3a9c 100644 --- a/bash_completion.d/pbuilder +++ b/bash_completion.d/pbuilder @@ -7,21 +7,73 @@ # adapted to pbuilder, the license is GPLv2 or later. # Copyright 2007 Junichi Uekawa -have pbuilder && +have pbuilder && { _pbuilder() { - local cur options + local cur prev command i COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - options='--create --update --build --login --execute --dumpconfig' + _get_comp_words_by_ref cur prev - if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $( compgen -W "$options" | grep "^$cur" ) ) - elif [ "${COMP_WORDS[1]}" = --build ]; then - COMPREPLY=( $( compgen -o filenames -G "$cur*.dsc" ) ) + + if [[ $COMP_CWORD -eq 1 ]]; then + COMPREPLY=( $( compgen -W '--create --update --build --login --execute \ + --dumpconfig create update build login execute dumpconfig' -- "$cur" ) ) + return 0 + fi + + _expand || return 0 + + # find the last option flag + if [[ $cur != -* ]]; then + i=$COMP_CWORD + while [[ $prev != -* && $i != 2 ]]; do + i=$((i-1)) + prev=${COMP_WORDS[i-1]} + done fi + command=${COMP_WORDS[1]} + + case $prev in + --basetgz) + # tgz file completion + _filedir 'tgz' + return 0 + ;; + --configfile|--logfile) + # Any file + _filedir + return 0 + ;; + --buildplace|--buildresults) + # Any directory + _filedir -d + return 0 + ;; + *) + # Provide available flags + COMPREPLY=( $( compgen -W '--basetgz --buildplace --mirror --othermirror \ + --http-proxy --distribution --architecture --components --buildresult \ + --aptcache --removepackages --extrapackages --configfile --hookdir \ + --debemail --debbuildopts --logfile --pkgname-logfile --aptconfdir \ + --timeout --override-config --binary-arch --preserve-buildplace \ + --bindmounts --debug --twice --autocleanaptcache --compressprog \ + --debootstrapopts --save-after-login --save-after-exec --debootstrap' \ + -- "$cur" ) ) + if [[ $prev = @(--aptcache|--hookdir) ]]; then + # Optionally provide a directory + _filedir -d + fi + if [[ $cur != -* && $command == @(--build|build) ]]; then + # dsc file completion + _filedir "dsc" + fi + return 0 + ;; + esac + return 0 } -[ "$have" ] && complete -F _pbuilder -o filenames pbuilder +complete -F _pbuilder pbuilder +} -- cgit v1.2.3