[Bash-completion-commits] [SCM] bash-completion branch, master, updated. e7494cf065d1988db6cefad51cd909214e966ba2

Ville Skyttä ville.skytta at iki.fi
Sat Oct 23 10:10:04 UTC 2010


The following commit has been merged in the master branch:
commit 7d87ca0a6d3510ccc2528a32d4b3f1686c5d37f4
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Oct 23 12:31:44 2010 +0300

    Improve wodim foo=bar completions.

diff --git a/completions/wodim b/completions/wodim
index 04c1ff2..763e473 100644
--- a/completions/wodim
+++ b/completions/wodim
@@ -1,35 +1,40 @@
 # bash completion for cdrecord/wodim
 
+# We set -o nospace and turn it off in several places for bash < 4
+# reasons; assuming bash >= 4 we could instead not turn it on
+# initially but only in the few cases where it's actually needed.
+
 have cdrecord || have wodim &&
 _cdrecord()
 {
     local cur prev i generic_options track_options track_mode
 
     COMPREPLY=()
-    _get_comp_words_by_ref cur prev
+    _get_comp_words_by_ref -n = cur prev
 
     # foo=bar style option
     if [[ "$cur" == *=* ]]; then
-        prev=${cur/=*/}
-        cur=${cur/*=/}
+        prev=${cur%%=*}
+        cur=${cur#*=}
         case $prev in
             textfile|cuefile)
+                compopt +o nospace &>/dev/null
                 _filedir
-                return 0
                 ;;
             blank)
+                compopt +o nospace &>/dev/null
                 COMPREPLY=( $( compgen -W 'help all fast track unreserve trtail
                     unclose session' -- "$cur" ) )
-                return 0
                 ;;
             driveropts)
+                compopt +o nospace &>/dev/null
                 COMPREPLY=( $( compgen -W 'burnfree noburnfree varirec=
                     gigarec= audiomaster forcespeed noforcespeed speedread
                     nospeedread singlesession nosinglesession hidecdr nohidecdr
                     tattooinfo tattoofile=' -- "$cur" ) )
-                return 0
                 ;;
         esac
+        return 0
     fi
 
     generic_options=( -version -v -V -d -silent -force -immed -dummy -dao \
@@ -67,9 +72,10 @@ _cdrecord()
         COMPREPLY=( "${COMPREPLY[@]}" \
             $( compgen -W '${generic_options[@]}' -- "$cur" ) )
     fi
-
+    [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \
+        compopt +o nospace &>/dev/null
 } &&
-complete -F _cdrecord cdrecord wodim
+complete -F _cdrecord -o nospace cdrecord wodim
 
 # Local variables:
 # mode: shell-script

-- 
bash-completion



More information about the Bash-completion-commits mailing list