blob: 85e6df1ae7e8bcc40894fb3de2ff123650671bfd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#compdef chmod gchmod
local curcontext="$curcontext" state line expl ret=1
local -a args privs
args=( '*:file:->files' '1:mode:->mode' )
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]')
;|
freebsd*|netbsd*|darwin*|dragonfly*)
args+=( "-h[operate on symlinks them self]" )
;|
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[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]'
)
;;
solaris*) privs=( 'l[mandatory locking]' ) ;;
esac
fi
_arguments -C -s "$args[@]" && ret=0
case "$state" in
mode)
compset -P \*,
compset -S ,\*
if [[ -prefix [0-7] ]]; then
_message -e number 'numeric mode'
elif compset -P '[a-z]#[+-=]'; then
_values -S '' privilege \
'r[read]' 'w[write]' 'x[execute]' \
's[set uid/gid]' 't[sticky]' \
'X[execute only if directory or executable to another]' \
"u[owner's current permissions]" \
"g[group's current permissions]" \
"o[other's current permissions]" \
"$privs[@]" && ret=0
else
suf=( -S '' )
compset -P '*'
_alternative -O suf \
'who:who:((u\:user g\:group a\:all o\:others))' \
'operators:operator:(+ - =)' && ret=0
fi
;;
files)
if [[ -n $opt_args[--reference] ]]; then
zmodload -F zsh/stat b:zstat 2>/dev/null
typeset -i8 ref=$(zstat +mode $opt_args[--reference])
_wanted files expl file _files -g "*(-.^f${ref#??})" && ret=0
elif [[ $line[1] = [0-7]## ]]; then
_wanted files expl file _files -g "*(-.^f$line[1])" && ret=0
else
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
specs+=( ${${(M)spec##[+-=]*}:+a}$spec )
done
_wanted files expl file _files -g "*(-.^f:${(j.,.)specs}:)" && ret=0
fi
;;
esac
return ret
|