# postconf(1)
#
comp_include _filedir _get_cword


_postconf()
{
    local cur prev pval len idx eqext

    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}
    if [[ $cur == '-' ]]; then
        COMPREPLY=(-c -d -e -h -m -l -n -v)
        return 0
    fi
    if [[ $prev == '-c' ]]; then
        _filedir -d
        return 0
    fi
    if [[ $prev == '-e' ]]; then
        cur=${cur#[\"\']}
        eqext='='
    fi
    len=${#cur}
    idx=0
    for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do
        if [[ "$cur" == "${pval:0:$len}" ]]; then
            COMPREPLY[$idx]="$pval$eqext"
            idx=$(($idx+1))
        fi
    done
    return 0
}
_postconf
