Make wtf bash < 4 compatible, fix -f handling.
This commit is contained in:
parent
474896f2c8
commit
cdc0bcc3c1
15
contrib/wtf
15
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user