# renice(8) completion


comp_include _get_cword _pgids _pids


_renice()
{
    local command cur curopt i

    COMPREPLY=()
    cur=`_get_cword`
    command=$1

    i=0
    # walk back through command line and find last option
    while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
        curopt=${COMP_WORDS[COMP_CWORD-$i]}
        case "$curopt" in
        -u)
            COMPREPLY=( $( compgen -u -- $cur ) )
            ;;
        -g)
            _pgids
            ;;
        -p|$command)
            _pids
            ;;
        esac
        i=$(( ++i ))
    done
} # _renice()
