From 5e343c89fbb59da914abcbf9d296dce9c43038fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 20 Apr 2011 14:22:23 +0300 Subject: [PATCH] Use _init_completion() in completions/b*. --- completions/bash-builtins | 32 ++++++++------------ completions/bind-utils | 6 ++-- completions/bitkeeper | 8 ++--- completions/bittorrent | 6 ++-- completions/bluez | 62 ++++++++++++++------------------------- completions/brctl | 9 +++--- completions/bzip2 | 11 +++---- 7 files changed, 49 insertions(+), 85 deletions(-) diff --git a/completions/bash-builtins b/completions/bash-builtins index 22229c37..3df3ddb3 100644 --- a/completions/bash-builtins +++ b/completions/bash-builtins @@ -2,12 +2,10 @@ # _alias() { - local cur + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur - - case $COMP_LINE in + case ${words[@]} in *[^=]) COMPREPLY=( $( compgen -A alias -- "$cur" ) ) ;; @@ -23,12 +21,10 @@ complete -F _alias -o nospace alias # _export() { - local cur + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur - - case $COMP_LINE in + case ${words[@]} in *=\$*) COMPREPLY=( $( compgen -v -P '$' -- "${cur#*=\$}" ) ) ;; @@ -49,10 +45,8 @@ complete -F _export -o default -o nospace export # _function() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return if [[ $1 == @(declare|typeset) ]]; then if [ "$prev" = -f ]; then @@ -60,10 +54,10 @@ _function() elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) ) fi - elif [ $COMP_CWORD -eq 1 ]; then + elif [ $cword -eq 1 ]; then COMPREPLY=( $( compgen -A function -- "$cur" ) ) else - COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" ) + COMPREPLY=( "() $( type -- ${words[1]} | sed -e 1,2d )" ) fi } && complete -F _function function declare typeset @@ -72,10 +66,8 @@ complete -F _function function declare typeset # _complete() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -o) diff --git a/completions/bind-utils b/completions/bind-utils index aef40d9a..79c02c7a 100644 --- a/completions/bind-utils +++ b/completions/bind-utils @@ -4,10 +4,8 @@ have nslookup || return _nslookup() { - local cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= srchlist= \ defname search port= querytype= type= recurse retry root timeout vc \ diff --git a/completions/bitkeeper b/completions/bitkeeper index 8d70cf12..8f1d9490 100644 --- a/completions/bitkeeper +++ b/completions/bitkeeper @@ -4,12 +4,10 @@ have bk || return _bk() { - local BKCMDS + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur - - BKCMDS="$( bk help topics | awk '/^ bk/ { print $4 }' | \ + local BKCMDS="$( bk help topics | awk '/^ bk/ { print $4 }' | \ xargs printf '%s ' )" COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) ) diff --git a/completions/bittorrent b/completions/bittorrent index de303c2a..ba940750 100644 --- a/completions/bittorrent +++ b/completions/bittorrent @@ -5,10 +5,8 @@ have btdownloadheadless.py || have btdownloadcurses.py || \ _btdownload() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in --responsefile|--saveas) diff --git a/completions/bluez b/completions/bluez index 3a3a5ec6..82f66dfe 100644 --- a/completions/bluez +++ b/completions/bluez @@ -31,11 +31,10 @@ _bluetooth_packet_types() _hcitool() { - local cur prev split=false arg - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local split=false _split_longopt && split=true case $prev in @@ -114,11 +113,10 @@ complete -F _hcitool hcitool _sdptool() { - local cur prev split=false - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local split=false _split_longopt && split=true case $prev in @@ -176,10 +174,8 @@ complete -F _sdptool sdptool _l2ping() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -i) @@ -198,10 +194,8 @@ complete -F _l2ping l2ping _rfcomm() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -f|--config) @@ -244,10 +238,8 @@ complete -F _rfcomm rfcomm _ciptool() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -i) @@ -281,10 +273,8 @@ complete -F _ciptool ciptool _dfutool() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -d|--device) @@ -313,10 +303,8 @@ complete -F _dfutool dfutool _hciconfig() { - local cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return local arg _get_first_arg @@ -360,10 +348,8 @@ complete -F _hciconfig hciconfig _hciattach() { - local cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) ) @@ -398,10 +384,8 @@ complete -F _hciattach hciattach _hid2hci() { - local cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 \ @@ -412,10 +396,8 @@ complete -F _hid2hci hid2hci _avctrl() { - local cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) ) diff --git a/completions/brctl b/completions/brctl index 6b08757d..8ae7dab7 100644 --- a/completions/brctl +++ b/completions/brctl @@ -4,13 +4,12 @@ have brctl || return _brctl() { - local cur command + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur - command=${COMP_WORDS[1]} + local command=${words[1]} - case $COMP_CWORD in + case $cword in 1) COMPREPLY=( $( compgen -W "addbr delbr addif delif \ setageing setbridgeprio setfd sethello \ diff --git a/completions/bzip2 b/completions/bzip2 index f19ea7d8..588400c3 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -4,10 +4,8 @@ have bzip2 || have pbzip2 || return _bzip2() { - local cur prev xspec - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -b|-h|--help|-p) @@ -16,15 +14,14 @@ _bzip2() esac if [[ "$cur" == -* ]]; then - local helpopts=`_parse_help ${COMP_WORDS[0]}` + local helpopts=`_parse_help ${words[0]}` COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ -- "$cur" ) ) return 0 fi - local IFS=$'\n' + local IFS=$'\n' xspec="*.bz2" - xspec="*.bz2" if [[ "$prev" == --* ]]; then [[ "$prev" == --decompress || \ "$prev" == --list || \