summaryrefslogtreecommitdiff
path: root/Completion/BSD/Command/_chflags
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/BSD/Command/_chflags')
-rw-r--r--Completion/BSD/Command/_chflags96
1 files changed, 64 insertions, 32 deletions
diff --git a/Completion/BSD/Command/_chflags b/Completion/BSD/Command/_chflags
index c9f26249d..43042bee4 100644
--- a/Completion/BSD/Command/_chflags
+++ b/Completion/BSD/Command/_chflags
@@ -1,47 +1,79 @@
#compdef chflags
-local flags 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]'
-)
+local flags args own='-g *(-u$EUID)'
+
+addflags() {
+ for 1 2; do
+ if [[ $1 = no* ]]; then
+ flags+=("(${1#no})$1[set the $2 flag]"
+ "($1)${1#no}[unset the $2 flag]")
+ else
+ flags+=("(no$1)$1[set the $2 flag]"
+ "($1)no$1[unset the $2 flag]")
+ fi
+ done
+}
+
+addflags \
+ uappnd 'user append-only' \
+ uchg 'user immutable'
if (( ! EUID )); then
- flags=( $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]'
- )
+ addflags \
+ arch archived \
+ nodump nodump \
+ sappnd 'system append-only' \
+ schg 'system immutable'
unset own
fi
-if [[ $OSTYPE = (freebsd|dragonfly|darwin)* ]]; then
- flags=( $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]'
- )
- (( EUID )) || flags=( $flags[@]
- '(nosunlnk)sunlnk[set the system undeletable flag]'
- '(sunlnk)nosunlnk[unset the system undeletable flag]'
+if [[ $OSTYPE = (darwin|dragonfly|freebsd|netbsd)* ]]; then
+ addflags opaque opaque
+
+ if [[ $OSTYPE = darwin* ]]; then
+ addflags hidden hidden
+ fi
+
+ if [[ $OSTYPE = (dragonfly|freebsd)* ]]; then
+ addlfags uunlnk 'user undeletable'
+ (( EUID )) || addflags sunlnk 'system undeletable'
+ fi
+
+ [[ $OSTYPE = dragonflybsd* ]] && {
+ addflags \
+ cache XXX \
+ nouhistory 'user nohistory'
+
+ (( EUID )) || addflags \
+ noscache XXX \
+ noshistory 'system nohistory'
+ }
+
+ [[ $OSTYPE = freebsd* ]] && addflags \
+ uarch archive \
+ uhidden hidden \
+ uoffline offline \
+ urdonly 'DOS, Windows and CIFS readonly' \
+ ureparse 'Windows reparse point' \
+ usparse 'sparse file' \
+ usystem 'DOS, Windows and CIFS system'
+
+fi
+
+if [[ $OSTYPE = (darwin|dragonfly|freebsd)* ]]; then
+ args=(
+ "-f[don't display diagnostic messages]"
+ '-v[verbose output]'
)
fi
-_arguments -s -A "-*" \
+_arguments -s -A "-*" : $args \
+ - opth \
+ '-h[act on symlinks]' \
+ - optR \
+ '-R[recurse directories]' \
'(-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"'