diff options
Diffstat (limited to 'completions/_mock')
-rw-r--r-- | completions/_mock | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/completions/_mock b/completions/_mock index b468148..df778a8 100644 --- a/completions/_mock +++ b/completions/_mock @@ -3,10 +3,10 @@ # Use of this file is deprecated. Upstream completion is available in # mock > 1.1.0, use that instead. -_mock() +_comp_cmd_mock() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return local plugins='tmpfs root_cache yum_cache bind_mount ccache' local cfgdir=/etc/mock count=0 i @@ -27,43 +27,45 @@ _mock() return ;; -r | --root) - COMPREPLY=($(compgen -W "$(command ls $cfgdir)" -- "$cur")) - COMPREPLY=(${COMPREPLY[@]/%.cfg/}) + _comp_compgen_split -- "$(command ls "$cfgdir")" && + COMPREPLY=("${COMPREPLY[@]/%.cfg/}") return ;; --configdir | --resultdir) - _filedir -d + _comp_compgen_filedir -d return ;; --spec) - _filedir spec + _comp_compgen_filedir spec return ;; --target) + # Case-insensitive BRE to match "compatible archs" + local regex_header='[cC][oO][mM][pP][aA][tT][iI][bB][lL][eE][[:space:]]\{1,\}[aA][rR][cC][hH][sS]' + # Yep, compatible archs, not compatible build archs # (e.g. ix86 chroot builds in x86_64 mock host) # This would actually depend on what the target root # can be used to build for... - COMPREPLY=($(compgen -W "$(command rpm --showrc | - command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p')" \ - -- "$cur")) + _comp_compgen_split -- "$(command rpm --showrc | command sed -ne \ + "s/^[[:space:]]*${regex_header}[[:space:]]*:[[:space:]]*\(.*\)/\1/p")" return ;; --enable-plugin | --disable-plugin) - COMPREPLY=($(compgen -W "$plugins" -- "$cur")) + _comp_compgen -- -W "$plugins" return ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - _filedir '@(?(no)src.r|s)pm' + _comp_compgen_filedir '@(?(no)src.r|s)pm' fi } && - complete -F _mock mock + complete -F _comp_cmd_mock mock # ex: filetype=sh |