summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command/_chmod
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command/_chmod')
-rw-r--r--Completion/Unix/Command/_chmod110
1 files changed, 63 insertions, 47 deletions
diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod
index af64b9eb9..3f6db7e91 100644
--- a/Completion/Unix/Command/_chmod
+++ b/Completion/Unix/Command/_chmod
@@ -1,54 +1,70 @@
-#compdef chmod gchmod
+#compdef chmod gchmod zf_chmod
-local curcontext="$curcontext" state line expl ret=1
-local -a args privs
+local curcontext="$curcontext" state line expl ret=1 variant
+local -a args privs aopts=( -A '-*' )
args=( '*: :->files' '1: :_file_modes' )
-if _pick_variant gnu=Free\ Soft unix --version; then
- args+=(
- '(-v --verbose -c --changes)'{-c,--changes}'[report changes made]'
- '(-v --verbose -c --changes)'{-v,--verbose}'[output a diagnostic for every file processed]'
- '(-f --silent --quiet)'{-f,--silent,--quiet}'[suppress most error messages]'
- '(--no-preserve-root)--preserve-root[fail to operate recursively on /]'
- "(--preserve-root)--no-preserve-root[don't treat / specially (default)]"
- '(1)--reference=[copy permissions of specified file]:file:_files'
- '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]'
- '(- : *)--help[display help information]'
- '(- : *)--version[display version information]'
- )
-else
- args+=(
- '-f[suppress most error messages]'
- '-R[change files and directories recursively]'
- )
- case $OSTYPE in
- freebsd*|dragonfly*|darwin*)
- args+=( '-v[output a diagnostic for every file processed]')
+_pick_variant -r variant -b zsh gnu=Free\ Soft $OSTYPE --version
+case "$variant" in
+ zsh)
+ # Assign, not append because zf_chmod only supports octal modes.
+ args=(
+ '-R[change files and directories recursively]'
+ '-s[enable paranoid behavior]'
+ '1: :_guard "[0-7]#" "octal mode"'
+ '*: :->files'
+ )
+ ;;
+ gnu)
+ aopts=()
+ args+=(
+ '(-v --verbose -c --changes)'{-c,--changes}'[report changes made]'
+ '(-v --verbose -c --changes)'{-v,--verbose}'[output a diagnostic for every file processed]'
+ '(-f --silent --quiet)'{-f,--silent,--quiet}'[suppress most error messages]'
+ '(--no-preserve-root)--preserve-root[fail to operate recursively on /]'
+ "(--preserve-root)--no-preserve-root[don't treat / specially (default)]"
+ '(1)--reference=[copy permissions of specified file]:file:_files'
+ '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]'
+ '(- : *)--help[display help information]'
+ '(- : *)--version[display version information]'
+ )
+ ;;
+ *)
+ args+=(
+ '-f[suppress most error messages]'
+ '-R[change files and directories recursively]'
+ )
;|
- freebsd*|netbsd*|darwin*|dragonfly*)
- args+=( "-h[operate on symlinks them self]" )
+ freebsd*|dragonfly*|darwin*)
+ args+=(
+ '-v[output a diagnostic for every file processed]'
+ )
;|
- freebsd*|openbsd*|netbsd*|darwin*|dragonfly*)
- args+=(
- '(-H -L -P)-L[follow all symlinks]'
- '(-H -L -P)-H[follow symlinks on the command line]'
- '(-H -L -P)-P[do not follow symlinks (default)]'
- )
+ freebsd*|netbsd*|darwin*|dragonfly*)
+ args+=(
+ '-h[operate on symlinks themselves]'
+ )
;|
- darwin*)
- args+=(
- '(1)-C[returns false if any of the named files have ACLs]'
- '(1)-N[remove ACLs from specified files]'
- '(1)-E[read ACL info from stdin as a sequential list of ACEs]'
- '(1)-i[removes inherited bit from all entries in named files ACLs]'
- '(1)-I[removes all inherited entries from named files ACLs]'
- )
+ freebsd*|openbsd*|netbsd*|darwin*|dragonfly*)
+ args+=(
+ '(-H -L -P)-L[follow all symlinks]'
+ '(-H -L -P)-H[follow symlinks on the command line]'
+ '(-H -L -P)-P[do not follow symlinks (default)]'
+ )
+ ;|
+ darwin*)
+ args+=(
+ '(1)-C[return false if any specified files have ACLs]'
+ '(1)-N[remove ACLs from specified files]'
+ '(1)-E[read ACL info from stdin as sequential list of ACEs]'
+ "(1)-i[remove inherited bit from all entries in specified files' ACLs]"
+ "(1)-I[remove all inherited entries from specified files' ACLs]"
+ )
;;
- esac
-fi
+esac
-_arguments -C -s "$args[@]" && ret=0
+_arguments -C -s -S $aopts "$args[@]" && ret=0
case "$state" in
files)
@@ -62,12 +78,12 @@ case "$state" in
local spec who op priv
local -a specs
for spec in ${(s:,:)line[1]}; do
- if [[ ${spec#*[+-=]} != [rwxst]## ]]; then
- _files && ret=0
- return ret
- fi
+ if [[ ${spec#*[+-=]} != [rwxst]## ]]; then
+ _files && ret=0
+ return ret
+ fi
- specs+=( ${${(M)spec##[+-=]*}:+a}$spec )
+ specs+=( ${${(M)spec##[+-=]*}:+a}$spec )
done
_wanted files expl file _files -g "*(-.^f:${(j.,.)specs}:)" && ret=0
fi