#compdef comm

autoload -U is-at-least

_comm() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'*--output-delimiter=[comm-help-delimiter]:STR:_default' \
'-1[comm-help-column-1]' \
'-2[comm-help-column-2]' \
'-3[comm-help-column-3]' \
'-z[comm-help-zero-terminated]' \
'--zero-terminated[comm-help-zero-terminated]' \
'--total[comm-help-total]' \
'--check-order[comm-help-check-order]' \
'(--check-order)--nocheck-order[comm-help-no-check-order]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':FILE1:_files' \
':FILE2:_files' \
&& ret=0
}

(( $+functions[_comm_commands] )) ||
_comm_commands() {
    local commands; commands=()
    _describe -t commands 'comm commands' commands "$@"
}

if [ "$funcstack[1]" = "_comm" ]; then
    _comm "$@"
else
    compdef _comm comm
fi
