summaryrefslogtreecommitdiffstats
path: root/completions/wol
diff options
context:
space:
mode:
Diffstat (limited to 'completions/wol')
-rw-r--r--completions/wol37
1 files changed, 20 insertions, 17 deletions
diff --git a/completions/wol b/completions/wol
index eada070..7e409a1 100644
--- a/completions/wol
+++ b/completions/wol
@@ -1,42 +1,45 @@
# wol(1) completion -*- shell-script -*-
-_wol()
+_comp_cmd_wol()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[pwhif]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | --help | --port | --passwd | --wait | -!(-*)[Vpw])
+ --version | --help | --port | --passwd | --wait | -${noargopts}[Vpw])
return
;;
- --host | --ipaddr | -!(-*)[hi])
+ --host | --ipaddr | -${noargopts}[hi])
# Broadcast addresses
local PATH=$PATH:/sbin
- COMPREPLY=($({
- ip addr show || ifconfig -a
+ _comp_compgen_split -- "$({
+ ip -c=never addr show || ip addr show || ifconfig -a
} 2>/dev/null |
- command sed -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' -ne \
- 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \
- 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p'))
- _known_hosts_real -- "$cur"
+ command sed \
+ -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' \
+ -ne 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' \
+ -ne 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p')"
+ _comp_compgen -a known_hosts -- "$cur"
return
;;
- --file | -!(-*)f)
- _filedir
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _mac_addresses
+ _comp_compgen_mac_addresses
} &&
- complete -F _wol wol
+ complete -F _comp_cmd_wol wol
# ex: filetype=sh