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

Ville Skyttä ville.skytta at iki.fi
Wed Oct 21 17:28:14 UTC 2009


The following commit has been merged in the master branch:
commit cdc0bcc3c1176a4f2925e2944593ca5c3eb89870
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Oct 21 20:27:58 2009 +0300

    Make wtf bash < 4 compatible, fix -f handling.

diff --git a/contrib/wtf b/contrib/wtf
index c1d19a6..4744e5f 100644
--- a/contrib/wtf
+++ b/contrib/wtf
@@ -11,9 +11,20 @@ _wtf()
     prev=${COMP_WORDS[COMP_CWORD-1]}
 
     [ "$prev" = -f ] && _filedir && return 0
+    [[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0
 
-    db=${ACRONYMDB:-/usr/share/misc/acronyms*}
-    COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db )" -- "${cur^^}" ) )
+    set -- "${COMP_WORDS[@]}"
+    while [ $# -gt 0 ]; do
+        if [ "$1" = -f ]; then
+            shift ; db=$1 ; break
+        fi
+        shift
+    done
+    [ -z $db ] && db=${ACRONYMDB:-/usr/share/misc/acronyms*}
+
+    [ ${BASH_VERSINFO[0]} -ge 4 ] && cur="${cur^^}"
+
+    COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur}" ) )
 } &&
 complete -F _wtf $filenames wtf
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list