summaryrefslogtreecommitdiffstats
path: root/completions/wtf
diff options
context:
space:
mode:
Diffstat (limited to 'completions/wtf')
-rw-r--r--completions/wtf29
1 files changed, 16 insertions, 13 deletions
diff --git a/completions/wtf b/completions/wtf
index 27fc10a..c565c56 100644
--- a/completions/wtf
+++ b/completions/wtf
@@ -1,42 +1,45 @@
# wtf completion -*- shell-script -*-
# Raphael Droz, 25/09/2009
-_wtf()
+_comp_cmd_wtf()
{
- local cur prev words cword addf
- _init_completion || return
+ local cur prev words cword comp_args addf
+ _comp_initialize -- "$@" || return
- [[ $prev == -f ]] && _filedir && return
+ [[ $prev == -f ]] && _comp_compgen_filedir && return
[[ ${words[*]} == *\ -f* ]] && addf= || addf=-f
if [[ $cur == -* ]]; then
- COMPREPLY=($addf)
+ COMPREPLY=(${addf:+"$addf"})
return
fi
- local db
+ local db="" has_db=""
set -- "${words[@]}"
while (($# > 0)); do
if [[ $1 == -f ]]; then
shift
- db=$1
+ if (($# > 0)); then
+ db=$1
+ has_db=set
+ fi
break
fi
shift
done
- if [[ ! -v db ]]; then
+ if [[ ! $has_db ]]; then
local f
for f in "${ACRONYMDB-}" /usr/share/misc/acronyms \
/usr/share/games/bsdgames/acronyms; do
- [[ -f $f ]] && db="$f" && break
+ [[ -f $f ]] && db="$f" has_db=set && break
done
- [[ -v db ]] || return
+ [[ $has_db ]] || return
fi
- COMPREPLY=($(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \
- -- "${cur^^}"))
+ _comp_compgen -c "${cur^^}" split \
+ -- "$(cut -f 1 -s "$db"* 2>/dev/null) $addf"
} &&
- complete -F _wtf wtf
+ complete -F _comp_cmd_wtf wtf
# ex: filetype=sh