# bash completion for mock -*- shell-script -*- # Use of this file is deprecated. Upstream completion is available in # mock > 1.1.0, use that instead. proc _mock { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return var plugins = ''tmpfs root_cache yum_cache bind_mount ccache'' var cfgdir = '/etc/mock', count = '0', i = '' for i in [$(words[@])] { [[ $count -eq $cword ]] && break if [[ "$i" == --configdir ]] { set cfgdir = $(words[((count+1))]) } elif [[ "$i" == --configdir=* ]] { set cfgdir = $(i/*=/) } set count = $shExpr('++count') } match $prev { with -h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\ --uniqueext|--rpmbuild_timeout|--sources|--cwd return 0 with -r|--root setglobal COMPREPLY = '( '$( compgen -W "$( command ls $cfgdir )" -- "$cur" ) ) setglobal COMPREPLY = '( '${COMPREPLY[@]/%.cfg/} ) return 0 with --configdir|--resultdir _filedir -d return 0 with --spec _filedir spec return 0 with --target # 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... setglobal COMPREPLY = '( '$( compgen -W "$( command rpm --showrc | \ sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \ -- "$cur" ) ) return 0 with --enable-plugin|--disable-plugin setglobal COMPREPLY = '( '$( compgen -W "$plugins" -- "$cur" ) ) return 0 } $split && return 0 if [[ "$cur" == -* ]] { setglobal COMPREPLY = '( '$( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } else { _filedir '@(?(no)src.r|s)pm' } } && complete -F _mock mock # ex: ts=4 sw=4 et filetype=sh