From a4f44972076ac86bde7f8b96c18b10807d580965 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Mon, 22 Apr 2019 22:04:24 -0500 Subject: 44242: Completion: Use _pick_variant -b to detect builtins --- Completion/Unix/Command/_ln | 115 ++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 58 deletions(-) (limited to 'Completion/Unix/Command/_ln') diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln index 3c1dcac76..339d327fe 100644 --- a/Completion/Unix/Command/_ln +++ b/Completion/Unix/Command/_ln @@ -1,6 +1,6 @@ #compdef ln gln zf_ln -local curcontext="$curcontext" state line ret=1 +local curcontext="$curcontext" state line ret=1 variant local -A opt_args local -a args opts @@ -9,67 +9,66 @@ args=( '-s[create symbolic links instead of hard links]' ) -local variant -_pick_variant -r variant gnu=gnu unix --help -if [[ $variant == gnu ]]; then - opts=(-S) - args=( - '(-b --backup)-b[create a backup of each existing destination file]' \ - '(-b --backup)--backup=[create a backup of each existing destination file]::method:(( - none\:"never create backups" - off\:"never create backups" - numbered\:"create numbered backup" - t\:"create numbered backup" - existing\:"same as numbered if numbered backups exist, otherwise same as simple" - nil\:"same as numbered if numbered backups exist, otherwise same as simple" - simple\:"always create simple backups" - never\:"always create simple backups"))' - '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]' - '(-f --force)'{-f,--force}'[remove existing destination files]' - '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]' - '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]' - '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]' - '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]' - '(-r --relative)'{-r,--relative}'[create symbolic links relative to link location]' - '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]' - '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix' - '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories' - '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]' - '(-v --verbose)'{-v,--verbose}'[print name of each linked file]' - '--help[display usage information and exit]' - '--version[display version information and exit]') -elif (( ${+builtins[ln]} )); then - args+=( - '-d[attempt to hard link directories]' - {-h,-n}'[do not dereference destination]' - '(-f)-i[prompt before removing destination files]') -else - case $OSTYPE in - darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) - args+=( - {-h,-n}'[do not dereference destination]' - ) +_pick_variant -r variant -b zsh gnu=gnu $OSTYPE --help +case $variant; in + gnu) + opts=(-S) + args=( + '(-b --backup)-b[create a backup of each existing destination file]' \ + '(-b --backup)--backup=[create a backup of each existing destination file]::method:(( + none\:"never create backups" + off\:"never create backups" + numbered\:"create numbered backup" + t\:"create numbered backup" + existing\:"same as numbered if numbered backups exist, otherwise same as simple" + nil\:"same as numbered if numbered backups exist, otherwise same as simple" + simple\:"always create simple backups" + never\:"always create simple backups"))' + '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]' + '(-f --force)'{-f,--force}'[remove existing destination files]' + '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]' + '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]' + '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]' + '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]' + '(-r --relative)'{-r,--relative}'[create symbolic links relative to link location]' + '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]' + '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix' + '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories' + '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]' + '(-v --verbose)'{-v,--verbose}'[print name of each linked file]' + '--help[display usage information and exit]' + '--version[display version information and exit]') + ;; + zsh) + args+=( + '-d[attempt to hard link directories]' + {-h,-n}'[do not dereference destination]' + '(-f)-i[prompt before removing destination files]') + ;; + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + {-h,-n}'[do not dereference destination]' + ) ;| - darwin*|dragonfly*|freebsd*|netbsd*) - args+=( - '-F[remove existing destination directories]' - '(-f)-i[prompt before removing destination files]' - '-v[print name of each linked file]' - ) + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '-F[remove existing destination directories]' + '(-f)-i[prompt before removing destination files]' + '-v[print name of each linked file]' + ) ;| - dragonfly*|freebsd*|netbsd*|openbsd*) - args+=( - '(-L)-P[create hard links directly to symbolic links]' - '(-P)-L[create hard links to symbolic link references]' - ) + dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + '(-L)-P[create hard links directly to symbolic links]' + '(-P)-L[create hard links to symbolic link references]' + ) ;| - dragonfly*|freebsd*) - args+=( - "-w[warn if source of a symbolic link doesn't currently exist]" - ) + dragonfly*|freebsd*) + args+=( + "-w[warn if source of a symbolic link doesn't currently exist]" + ) ;; - esac -fi +esac _arguments -C -s $opts : \ $args \ -- cgit 1.4.1