#-*-sh-*- if _have checkrestart; then _checkrestart(){ # shellcheck disable=2034 local cur prev words cword # -s as --exclude=ARG -> exclude= arg # -n: means do not break words at : _init_completion -s -n: || return #_expand # replace ~ case "$prev" in -b|--blocklistfile) _filedir ;; -x|--exclude) if [[ $cur = *:* ]]; then # -x file:/roo prev=${cur%%?(\\):*} cur=${cur#*:} case "$prev" in package) COMPREPLY=($(apt-cache --no-generate pkgnames "$cur" 2>/dev/null)) ;; unit|suggested-unit|dangerous-unit) # based on _services from bash-completion COMPREPLY=($(compgen -W "$(systemctl list-units --full --all 2>/dev/null | awk '$1~/\.service$/{print $1}')" -- "$cur")) _filedir ;; suggested-initscript|dangerous-initscript) COMPREPLY=($(compgen -W "$(command find /etc/init.d)" -- "$cur")) ;; program) _pnames && _filedir ;; pid) _pids ;; file) _filedir ;; esac else # -x f compopt -o nospace COMPREPLY=($(compgen -W "package: unit: program: pid: file: unit: suggested-unit: dangerous-unit: suggested-initscript: dangerous-initscript: " -- "$cur")) fi ;; --exclude-package) COMPREPLY=($(apt-cache --no-generate pkgnames "$cur" 2>/dev/null)) ;; --exclude-unit|--dont-suggest-unit|--dangerous-unit) COMPREPLY=($(compgen -W "$(systemctl list-units --full --all 2>/dev/null | awk '$1~/\.service$/{print $1}')" -- "$cur")) _filedir ;; --exclude-program) _pnames && _filedir;; --exclude-pid) _pids ;; --exclude-file) _filedir ;; --dont-suggest-initscript|--dangerous-initscript) COMPREPLY=($(compgen -W "$(command find /etc/init.d)" -- "$cur"));; *) if [[ "$cur" == -* ]] || [ "$cword" = 1 ]; then # --hel or 'checkrestart COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) else _filedir fi ;; esac } complete -F _checkrestart checkrestart fi