blob: 37db161d015f11befeb96c5f2b4518f4e43914b6 (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
#autoload
local state=qual expl char delim timespec
local -a alts
local -A specmap
while [[ -n $PREFIX ]]; do
char=$PREFIX[1]
compset -p 1
case $char in
([-/F.@=p*rwxAIERWXsStUG^MTNDn,])
# no argument
;;
(%)
# optional b, c
if [[ $PREFIX[1] = [bc] ]]; then
compset -p 1
fi
;;
(f)
if ! compset -P "[-=+][0-7?]##"; then
if [[ -z $PREFIX ]]; then
_delimiters qualifier-f
return
elif ! _globqual_delims; then
# still completing mode spec
_message -e modes "mode spec"
return
fi
fi
;;
(P)
# skip delimited prefix
if [[ -z $PREFIX ]]; then
_delimiters qualifier-P
return
elif ! _globqual_delims; then
# can't suggest anything here
_message -e prefix prefix
return
fi
;;
(e)
# complete/skip delimited command line
if [[ -z $PREFIX ]]; then
_delimiters qualifer-e
return
elif ! _globqual_delims; then
# still completing command to eval
compset -q
_normal
return
fi
;;
(+)
# complete/skip command name (no delimiters)
if [[ $PREFIX = [[:IDENT:]]# ]]; then
# either nothing there yet, or still on name
_command_names
return
fi
compset -P '[[:IDENT:]]##'
;;
(d)
# complete/skip device
if ! compset -p '[[:digit:]]##'; then
_message -e device-ids "device ID"
return
fi
;;
(l)
# complete/skip link count
if ! compset -P '([-+]|)[[:digit:]]##'; then
_message -e numbers "link count"
return
fi
;;
(u)
# complete/skip UID or delimited user
if ! compset -P '[[:digit:]]##'; then
if [[ -z $PREFIX ]]; then
_delimiters qualifier-u
return
elif ! _globqual_delims; then
# still completing user
_users -S $delim
return
fi
fi
;;
(g)
# complete/skip GID or delimited group
if ! compset -P '[[:digit:]]##'; then
if [[ -z $PREFIX ]]; then
_delimiters qualifier-g
return
elif ! _globqual_delims; then
# still completing group
_groups -S $delim
return
fi
fi
;;
([amc])
if ! compset -P '([Mwhmsd]|)([-+]|)<->'; then
# complete/skip relative time spec
alts=()
timespec=$PREFIX[1]
if ! compset -P '[Mwhmsd]' && [[ -z $PREFIX ]]; then
alts+=("time-specifiers:time specifier:\
((M\:months w\:weeks h\:hours m:\minutes s\:seconds d\:days))")
fi
if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then
alts+=("senses:sense:((-\:less\ than +\:more\ than))")
fi
specmap=( M months w weeks h hours m minutes s seconds '(|+|-|d)' days)
alts+=('digits:digit ('${${specmap[(K)$timespec]}:-invalid time specifier}'):' )
_alternative $alts
return
fi
;;
(L)
# complete/skip file size
if ! compset -P '([kKmMgGtTpP]|)([-+]|)<->'; then
# complete/skip size spec
alts=()
if ! compset -P '[kKmMgGtTpP]' && [[ -z $PREFIX ]]; then
alts+=(
"size-specifiers:size specifier:\
((k\:kb m\:mb g\:gb t\:tb p\:512-byte\ blocks))")
fi
if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then
alts+=("senses:sense:((-\:less\ than +\:more\ than))")
fi
alts+=('digits:digit: ')
_alternative $alts
return
fi
;;
([oO])
# complete/skip sort spec
if ! compset -P "?"; then
alts=(
"n:lexical order of name"
"L:size of file"
"l:number of hard links"
"a:last access time"
"m:last modification time"
"c:last inode change time"
"d:directory depth"
"N:no sorting"
"e:execute code"
"+:+ command name"
)
_describe -t sort-specifiers "sort specifier" alts -Q -S ''
return
elif [[ $IPREFIX[-1] = e ]]; then
if [[ -z $PREFIX ]]; then
_delimiters qualifier-oe
return
elif ! _globqual_delims; then
compset -q
_normal
return
fi
elif [[ $IPREFIX[-1] = + ]]; then
if [[ $PREFIX = [[:IDENT:]]# ]]; then
# either nothing there yet, or still on name
_command_names
return
fi
fi
;;
(\[)
# complete/skip range: check for closing bracket
if ! compset -P "(-|)[[:digit:]]##(,(-|)[[:digit:]]##|)]"; then
if compset -P "(-|)[[:digit:]]##,"; then
_message "end of range"
else
_message "start of range"
fi
return
fi
;;
(:)
# complete modifiers and don't stop completing them
_history_modifiers q
return
;;
esac
done
case $state in
(qual)
local -a quals
quals=(
"/:directories"
"F:non-empty directories"
".:plain files"
"@:symbolic links"
"=:sockets"
"p:name pipes (FIFOS)"
"*:executable plain files"
"%:device files"
"r:owner-readable"
"w:owner-writeable"
"x:owner-executable"
"A:group-readable"
"I:group-writeable"
"E:group-executable"
"R:world-readable"
"W:world-writeable"
"X:world-executable"
"s:setuid"
"S:setgid"
"t:sticky bit set"
"f:+ access rights"
"e:execute code"
"+:+ command name"
"d:+ device"
"l:+ link count"
"U:owned by EUID"
"G:owned by EGID"
"u:+ owning user"
"g:+ owning group"
"a:+ access time"
"m:+ modification time"
"c:+ inode change time"
"L:+ size"
"^:negate qualifiers"
"-:follow symlinks toggle"
"M:mark directories"
"T:mark types"
"N:use NULL_GLOB"
"D:glob dots"
"n:numeric glob sort"
"o:+ sort order, up"
"O:+ sort order, down"
"P:prepend word"
"Y:+ at most ARG matches"
"[:+ range of files"
"):end of qualifiers"
"\::modifier"
)
_describe -t globquals "glob qualifier" quals -Q -S ''
;;
esac
|