summary refs log tree commit diff
path: root/Completion/Linux/Command/_chattr
blob: bf46d8b89553ac59d014adf56f0a5b8f9267d894 (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
#compdef chattr

local ret=1
local -a context line state state_descr
local -A opt_args val_args

_arguments -s -S : \
  '-f[suppress most error messages]' \
  "-p+[set file's project number]:project number" \
  '-R[act recursively]' \
  '-V[output verbosely]' \
  "-v+[set file's version/generation number]:version/generation number" \
  '1: :->attrs' \
  '*: :_files' \
&& ret=0

[[ $state == attrs ]] &&
if compset -P '*[=+-]'; then
  # These modes can't be changed with chattr: [EhINXZ]
  _values -S '' attribute \
    'A[no atime updates]' \
    'a[append only]' \
    'C[no copy on write]' \
    'c[compressed]' \
    'D[no synchronous directory updates]' \
    'd[no dump]' \
    'e[extent format]' \
    'i[immutable]' \
    'j[data journalling]' \
    'P[project hierarchy]' \
    'S[synchronous updates]' \
    's[secure deletion]' \
    'T[top of directory hierarchy]' \
    't[no tail-merging]' \
    'u[undeletable]' \
  && ret=0
else
  compset -P '*'
  _values -S '' operator = + - && ret=0
fi

return ret