summaryrefslogtreecommitdiffstats
path: root/completions/find
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--completions/find65
-rw-r--r--completions/find_member18
2 files changed, 42 insertions, 41 deletions
diff --git a/completions/find b/completions/find
index 64121ed..92c7fa8 100644
--- a/completions/find
+++ b/completions/find
@@ -2,53 +2,53 @@
# This makes heavy use of ksh style extended globs and contains Linux specific
# code for completing the parameter to the -fstype option.
-_find()
+_comp_cmd_find()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local i
- for i in ${!words[*]}; do
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -@(exec|ok)?(dir) ]]; then
- _command_offset $((i + 1))
+ _comp_command_offset $((i + 1))
return
fi
done
case $prev in
-maxdepth | -mindepth)
- COMPREPLY=($(compgen -W '{0..9}' -- "$cur"))
+ _comp_compgen -- -W '{0..9}'
return
;;
-newer | -anewer | -cnewer | -fls | -fprint | -fprint0 | -fprintf | -name | -[il]name | \
-ilname | -wholename | -[il]wholename | -samefile)
- _filedir
+ _comp_compgen_filedir
return
;;
-fstype)
- _fstypes
+ _comp_compgen_fstypes
[[ $OSTYPE == *bsd* ]] &&
- COMPREPLY+=($(compgen -W 'local rdonly' -- "$cur"))
+ _comp_compgen -a -- -W 'local rdonly'
return
;;
-gid)
- _gids
+ _comp_compgen_gids
return
;;
-group)
- COMPREPLY=($(compgen -g -- "$cur" 2>/dev/null))
+ _comp_compgen -- -g
return
;;
-xtype | -type)
- COMPREPLY=($(compgen -W 'b c d p f l s' -- "$cur"))
+ _comp_compgen -- -W 'b c d p f l s'
return
;;
-uid)
- _uids
+ _comp_compgen_uids
return
;;
-user)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-[acm]min | -[acm]time | -inum | -path | -ipath | -regex | -iregex | -links | -perm | \
@@ -57,35 +57,34 @@ _find()
return
;;
-regextype)
- COMPREPLY=($(compgen -W 'emacs posix-awk posix-basic posix-egrep
- posix-extended' -- "$cur"))
+ _comp_compgen -- -W 'emacs posix-awk posix-basic posix-egrep
+ posix-extended'
return
;;
esac
- local i exprfound=false
+ local i exprfound=""
# set exprfound to true if there is already an expression present
for i in "${words[@]}"; do
- [[ $i == [-\(\),\!]* ]] && exprfound=true && break
+ [[ $i == [-\(\),\!]* ]] && exprfound=set && break
done
# handle case where first parameter is not a dash option
- if ! $exprfound && [[ $cur != [-\(\),\!]* ]]; then
- _filedir -d
+ if [[ ! $exprfound && $cur != [-\(\),\!]* ]]; then
+ _comp_compgen_filedir -d
return
fi
# complete using basic options
- COMPREPLY=($(compgen -W '-daystart -depth -follow -help
- -ignore_readdir_race -maxdepth -mindepth -mindepth -mount
- -noignore_readdir_race -noleaf -regextype -version -warn -nowarn -xdev
- -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false
- -fstype -gid -group -ilname -iname -inum -ipath -iregex -iwholename
- -links -lname -mmin -mtime -name -newer -nogroup -nouser -path -perm
- -readable -regex -samefile -size -true -type -uid -used -user
- -wholename -writable -xtype -context -delete -exec -execdir -fls
- -fprint -fprint0 -fprintf -ls -ok -okdir -print -print0 -printf -prune
- -quit' -- "$cur"))
+ _comp_compgen -- -W '-daystart -depth -follow -help -ignore_readdir_race
+ -maxdepth -mindepth -mindepth -mount -noignore_readdir_race -noleaf
+ -regextype -version -warn -nowarn -xdev -amin -anewer -atime -cmin
+ -cnewer -ctime -empty -executable -false -fstype -gid -group -ilname
+ -iname -inum -ipath -iregex -iwholename -links -lname -mmin -mtime
+ -name -newer -nogroup -nouser -path -perm -readable -regex -samefile
+ -size -true -type -uid -used -user -wholename -writable -xtype -context
+ -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir
+ -print -print0 -printf -prune -quit'
if ((${#COMPREPLY[@]} != 0)); then
# this removes any options from the list of completions that have
@@ -100,14 +99,14 @@ _find()
for i in "${words[@]}"; do
[[ $i && -v onlyonce["$i"] ]] || continue
for j in "${!COMPREPLY[@]}"; do
- [[ ${COMPREPLY[j]} == "$i" ]] && unset 'COMPREPLY[j]'
+ [[ ${COMPREPLY[j]} == "$i" ]] && unset -v 'COMPREPLY[j]'
done
done
fi
- _filedir
+ _comp_compgen -a filedir
} &&
- complete -F _find find
+ complete -F _comp_cmd_find find
# ex: filetype=sh
diff --git a/completions/find_member b/completions/find_member
index cf30c70..d2620e8 100644
--- a/completions/find_member
+++ b/completions/find_member
@@ -1,25 +1,27 @@
# mailman find_member completion -*- shell-script -*-
-_find_member()
+_comp_cmd_find_member()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-l | -x | --listname | --exclude)
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--listname --exclude --owners --help' \
- -- "$cur"))
+ _comp_compgen -- -W '--listname --exclude --owners --help'
fi
} &&
- complete -F _find_member find_member
+ complete -F _comp_cmd_find_member find_member
# ex: filetype=sh