about summary refs log tree commit diff
path: root/Completion/BSD/Command/_chflags
blob: bfbaa018f63e09863ff7fe8fa685958a8dabee30 (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
#compdef chflags

local flags args own='-g *(-u$EUID)'

flags=(
  '(noopaque)opaque[set the opaque flag]'
  '(opaque)noopaque[unset the opaque flag]'
  '(dump)nodump[set the nodump flag]'
  '(nodump)dump[unset the nodump flag]'
  '(nouappnd)uappnd[set the user append-only flag]'
  '(uappnd)nouappnd[unset the user append-only flag]'
  '(nouchg)uchg[set the user immutable flag]'
  '(uchg)nouchg[unset the user immutable flag]'
)

if (( ! EUID )); then
  flags+=(
    '(noarch)arch[set the archived flag]'
    '(arch)noarch[unset the archived flag]'
    '(nosappnd)sappnd[set the system append-only flag]'
    '(sappnd)nosappnd[unset the system append-only flag]'
    '(noschg)schg[set the system immutable flag]'
    '(schg)noschg[unset the system immutable flag]'
  )
  unset own
fi

if [[ $OSTYPE = (freebsd|dragonfly|darwin)* ]]; then
  flags+=(
    '(nouunlnk)uunlnk[set the user undeletable flag]'
    '(uunlnk)nouunlnk[unset the user undeletable flag]'
    '(nohidden)hidden[set the hidden flag]'
    '(hidden)nohidden[unset the hidden flag]'
  )
  [[ $OSTYPE = freebsd* ]] && flags+=(
    '(uoffline)offline[set the offline attribute]'
    '(offline)uoffline[unset the offline attribute]'
    '(urdonly)rdonly[set readonly flag]'
    '(rdonly)urdonly[unset readonly flag]'
    '(usparse)sparse[set the sparse attribute]'
    '(sparse)usparse[unset the sparse attribute]'
    '(usystem)system[set system flag]'
    '(system)usystem[unset system flag]'
    '(ureparse)reparse[set the Windows reparse point attribute]'
    '(reparse)ureparse[unset the Windows reparse point attribute]'
    '(uunlnk)unlnk[set undeletable flag]'
    '(unlnk)uunlnk[unset undeletable flag]'
  )

  (( EUID )) || flags+=(
    '(nosunlnk)sunlnk[set the system undeletable flag]'
    '(sunlnk)nosunlnk[unset the system undeletable flag]'
  )
  args=(
    "-f[don't display diagnostic messages]"
    '-h[act on symlinks]'
    '-v[verbose output]'
  )
fi

_arguments -s -A "-*" $args \
  '(-L -P)-H[follow symlinks on the command line (specify with -R)]' \
  '(-H -P)-L[follow all symlinks (specify with -R)]' \
  '(-L -H)-P[do not follow symlinks (specify with -R)]' \
  '-R[recurse directories]' \
  ':file flag:_values -s , "file flags" $flags[@]' \
  '*:file:_files "$own"'