mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 04:40:59 +01:00
42931: completion for several utilities especially for checksums across a variety of systems
This commit is contained in:
parent
594f2ff06e
commit
64ef1eddfd
10 changed files with 485 additions and 81 deletions
48
Completion/Unix/Command/_readlink
Normal file
48
Completion/Unix/Command/_readlink
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue