diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2018-08-27 13:31:04 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2018-08-27 13:31:04 +0200 |
commit | 719a715614f2182a76b30ad27a327d70a86f34f1 (patch) | |
tree | a437eb29da8035bf7c2e30506c08fe6f15719871 /Completion/Unix/Command/_readlink | |
parent | 7da8d19c224860ae4d6aa3f077fca7f734f20d88 (diff) | |
parent | ef61918398517473b9b594690a3be375f607cebe (diff) | |
download | zsh-719a715614f2182a76b30ad27a327d70a86f34f1.tar.gz zsh-719a715614f2182a76b30ad27a327d70a86f34f1.zip |
Merge tag 'zsh-5.5.1-test-2' into debian
Test release: 5.5.1-test-2.
Diffstat (limited to 'Completion/Unix/Command/_readlink')
-rw-r--r-- | Completion/Unix/Command/_readlink | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_readlink b/Completion/Unix/Command/_readlink new file mode 100644 index 000000000..36bd43752 --- /dev/null +++ b/Completion/Unix/Command/_readlink @@ -0,0 +1,48 @@ +#compdef readlink greadlink + +local variant ret=1 +local -a context line state state_descr args copts aopts=( -A '-*' ) +local -A opt_args + +# We can't use groups here because it would complicate the option filtering +copts=( -e -f -m --canonicalize --canonicalize-existing --canonicalize-missing ) + +args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + # Delimiter options + # (Note: GNU `readlink` won't let you use -n with multiple files) + '(-n -z --no-newline --zero)'{-n,--no-newline}'[suppress trailing newline]' + '(-n -z --no-newline --zero)'{-z,--zero}'[use NUL as output delimiter]' + # Verbosity options + '(-q -s -v --quiet --silent --verbose)'{-q,-s,--quiet,--silent}'[suppress most error messages]' + '(-q -s -v --quiet --silent --verbose)'{-v,--verbose}'[show error messages]' + # Canonicalisation options + "(${(j< >)copts})"{-e,--canonicalize-existing}'[canonicalize paths (all components must exist)]' + "(${(j< >)copts})"{-f,--canonicalize}'[canonicalize paths]' + "(${(j< >)copts})"{-m,--canonicalize-missing}'[canonicalize paths (components may be missing)]' +) + +# Filter out non-GNU options if applicable +if _pick_variant gnu='Free Soft' unix --version; then + aopts=( ) +else + case $OSTYPE in + darwin*) args=( ${(@M)args:#(|*\))-[n]\[*} ) ;; + netbsd*) args=( ${(@M)args:#(|*\))-[fnqsv]\[*} ) ;; + dragonfly*|*bsd*) args=( ${(@M)args:#(|*\))-[fn]\[*} ) ;; + *) args=( ) ;; + esac +fi + +_arguments -s -S $aopts : $args '*: :->files' && ret=0 + +# File arguments must be symlinks unless a canonicalisation option is given +[[ $state == files ]] && +if [[ ${opt_args[(i)(${~${(j<|>)copts}})]} ]]; then + _files && ret=0 +else + _files -g '*(@)' && ret=0 +fi + +return ret |