From eea696d9cce1af91d15289614f102c15a0b5cd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 12 Jun 2009 20:18:09 +0300 Subject: [PATCH] Use _split_longopt in bluez-utils. --- CHANGES | 8 ++++---- contrib/bluez-utils | 43 +++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index 4a65cf47..a4ce8937 100644 --- a/CHANGES +++ b/CHANGES @@ -63,10 +63,10 @@ bash-completion (1.x) input in external command arguments. * Add _split_longopt() helper for improved handling of long options that take arguments in both "--foo bar" and "--foo=bar" formats. - * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, - cpio, dpkg, iptables, make, mc, mii-diag, mii-tool, mkinitrd, pkg-config, - postgresql, quota, reportbug, samba, smartctl, yum, and generic long option - completion (Alioth: #311398). + * Use _split_longopt to improve and clean up aspell, bluez-utils, chgrp, + chown, chkconfig, cpio, dpkg, iptables, make, mc, mii-diag, mii-tool, + mkinitrd, pkg-config, postgresql, quota, reportbug, samba, smartctl, yum, + and generic long option completion (Alioth: #311398). * Add chown --from and --reference value completions. * Add chgrp --reference value completion. * Do not assume all --foo= options take filenames in generic long option diff --git a/contrib/bluez-utils b/contrib/bluez-utils index f2223231..8300ef2b 100644 --- a/contrib/bluez-utils +++ b/contrib/bluez-utils @@ -46,35 +46,30 @@ _get_command() _hcitool() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in -i) _bluetooth_devices return 0; ;; + --role) + COMPREPLY=( $( compgen -W 'm s' -- $cur ) ) + return 0; + ;; + --pkt-type) + _bluetooth_packet_types + return 0; + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --role) - COMPREPLY=( $( compgen -W 'm s' -- $cur ) ) - return 0; - ;; - --pkt-type) - _bluetooth_packet_types - return 0; - ;; - esac - fi - + $split && return 0 _get_command if [ -z $command ]; then @@ -95,8 +90,8 @@ _hcitool() ;; cc) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--role= \ - --pkt-type=' -- $cur ) ) + COMPREPLY=( $( compgen -W '--role \ + --pkt-type' -- $cur ) ) else _count_args if [ $args -eq 2 ]; then @@ -137,12 +132,14 @@ complete -F _hcitool hcitool _sdptool() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in --bdaddr) _bluetooth_adresses @@ -150,6 +147,8 @@ _sdptool() ;; esac + $split && return 0 + _get_command if [ -z $command ]; then if [[ "$cur" == -* ]]; then @@ -178,8 +177,8 @@ _sdptool() ;; add) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--handle= \ - --channel=' -- $cur ) ) + COMPREPLY=( $( compgen -W '--handle \ + --channel' -- $cur ) ) else _bluetooth_services fi