[484] | 1 | [ -z "$BASH_VERSION" ] && return |
---|
| 2 | |
---|
| 3 | _filedir() |
---|
| 4 | { |
---|
| 5 | local IFS=$'\t\n' xspec #glob |
---|
| 6 | |
---|
| 7 | #glob=$(set +o|grep noglob) # save glob setting. |
---|
| 8 | #set -f # disable pathname expansion (globbing) |
---|
| 9 | |
---|
| 10 | xspec=${1:+"!*.$1"} # set only if glob passed in as $1 |
---|
| 11 | COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \ |
---|
| 12 | $( compgen -d -- "$cur" ) ) |
---|
| 13 | #eval "$glob" # restore glob setting. |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | _vbuilder() |
---|
| 17 | { |
---|
| 18 | local opts cur prev first |
---|
| 19 | COMPREPLY=() |
---|
| 20 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 21 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 22 | first="${COMP_WORDS[1]}" |
---|
| 23 | |
---|
| 24 | ## The basic options we'll complete. |
---|
[486] | 25 | options="--version --arch --dist-upgrade --unionfs --target --with-compat32" |
---|
[679] | 26 | actions="--clean --build --build-rpm --install-rpm --remove-rpm \ |
---|
| 27 | clean build build-rpm install-rpm remove-rpm" |
---|
[484] | 28 | opts="$options $actions" |
---|
| 29 | |
---|
| 30 | _arch=$(rpm --eval %_arch) |
---|
| 31 | |
---|
| 32 | in_options=0 |
---|
| 33 | |
---|
| 34 | ## Complete the arguments to some of the basic commands. |
---|
| 35 | case "${prev}" in |
---|
| 36 | --version) |
---|
| 37 | if [ "$_arch" = "x86_64" ]; then |
---|
[690] | 38 | local running="VineSeed VineSeed_i386 5.1 5.1_i386 4.2_i386" |
---|
[484] | 39 | else |
---|
[690] | 40 | local running="VineSeed 5.1 4.2" |
---|
[484] | 41 | fi |
---|
| 42 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 43 | ;; |
---|
| 44 | |
---|
| 45 | --arch) |
---|
| 46 | local running="i386 ppc x86_64" |
---|
| 47 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 48 | ;; |
---|
| 49 | |
---|
| 50 | --target) |
---|
| 51 | local running="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/")" |
---|
| 52 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 53 | ;; |
---|
| 54 | |
---|
[679] | 55 | --build-rpm|build-rpm) |
---|
[484] | 56 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
| 57 | _filedir 'src.rpm' |
---|
| 58 | fi |
---|
| 59 | ;; |
---|
| 60 | |
---|
[679] | 61 | --install-rpm|install-rpm|--remove-rpm|remove-rpm) |
---|
[484] | 62 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
| 63 | _filedir 'rpm' |
---|
| 64 | fi |
---|
| 65 | ;; |
---|
| 66 | |
---|
| 67 | *) |
---|
| 68 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
---|
| 69 | #return 0 |
---|
| 70 | ;; |
---|
| 71 | esac |
---|
| 72 | |
---|
| 73 | if [[ "${cur}" == -* ]] ; then |
---|
| 74 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
---|
| 75 | #return 0 |
---|
| 76 | fi |
---|
| 77 | |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | complete -o filenames -o nospace -F _vbuilder vbuilder |
---|
| 81 | |
---|
| 82 | ### end of file |
---|