#compdef rm

autoload -U is-at-least

_rm() {
    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[@]}" : \
'--interactive=[rm-help-interactive]' \
'-f[rm-help-force]' \
'--force[rm-help-force]' \
'-i[rm-help-prompt-always]' \
'-I[rm-help-prompt-once]' \
'--one-file-system[rm-help-one-file-system]' \
'--no-preserve-root[rm-help-no-preserve-root]' \
'--preserve-root[rm-help-preserve-root]' \
'-r[rm-help-recursive]' \
'-R[rm-help-recursive]' \
'--recursive[rm-help-recursive]' \
'-d[rm-help-dir]' \
'--dir[rm-help-dir]' \
'-v[rm-help-verbose]' \
'--verbose[rm-help-verbose]' \
'--presume-input-tty[]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_rm" ]; then
    _rm "$@"
else
    compdef _rm rm
fi
