dav_completion() {
    local out
    local cmd_res

    out="$(${COMP_WORDS[0]} complete $COMP_CWORD ${COMP_WORDS[@]})"
    cmd_res=$?

    if [[ $cmd_res -eq 10 ]]; then
        compopt -o nospace
    fi
    if [[ $cmd_res -eq 12 ]]; then
        compopt -o default
        COMPREPLY=()
    else
        IFS=$'\n' declare -ga 'COMPREPLY=($out)'
    fi
}

complete -F dav_completion dav

