#compdef mv

autoload -U is-at-least

_mv() {
    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[@]}" : \
'--backup=[make a backup of each existing destination file]' \
'-S+[override the usual backup suffix]:SUFFIX:_default' \
'--suffix=[override the usual backup suffix]:SUFFIX:_default' \
'--update=[move only when the SOURCE file is newer than the destination file or when the destination file is missing]' \
'(-T --no-target-directory)-t+[mv-help-target-directory]:DIRECTORY:_files -/' \
'(-T --no-target-directory)--target-directory=[mv-help-target-directory]:DIRECTORY:_files -/' \
'--context=[mv-help-context]' \
'-f[mv-help-force]' \
'--force[mv-help-force]' \
'-i[mv-help-interactive]' \
'--interactive[mv-help-interactive]' \
'-n[mv-help-no-clobber]' \
'--no-clobber[mv-help-no-clobber]' \
'--strip-trailing-slashes[mv-help-strip-trailing-slashes]' \
'-b[like --backup but does not accept an argument]' \
'-u[like --update but does not accept an argument]' \
'-T[mv-help-no-target-directory]' \
'--no-target-directory[mv-help-no-target-directory]' \
'-v[mv-help-verbose]' \
'--verbose[mv-help-verbose]' \
'-g[mv-help-progress]' \
'--progress[mv-help-progress]' \
'-Z[mv-help-selinux]' \
'--debug[mv-help-debug]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_mv" ]; then
    _mv "$@"
else
    compdef _mv mv
fi
