summaryrefslogtreecommitdiff
path: root/Completion/BSD/Command
diff options
context:
space:
mode:
authorMatthew Martin <phy1729@gmail.com>2017-12-12 23:00:59 -0600
committerOliver Kiddle <opk@zsh.org>2018-01-03 17:11:00 +0100
commitdd824080cacd64289281ae6088732d6b63942728 (patch)
treeacd25371bd2ca7bc8c7b876d8180b05a15a05d83 /Completion/BSD/Command
parent99cf61fd4211dcb99142f683230947481c05eb93 (diff)
downloadzsh-dd824080cacd64289281ae6088732d6b63942728.tar.gz
zsh-dd824080cacd64289281ae6088732d6b63942728.zip
42117: use anonymous function rather than define one in user namespace
Diffstat (limited to 'Completion/BSD/Command')
-rw-r--r--Completion/BSD/Command/_chflags80
1 files changed, 42 insertions, 38 deletions
diff --git a/Completion/BSD/Command/_chflags b/Completion/BSD/Command/_chflags
index 075782cd9..ddf61b25e 100644
--- a/Completion/BSD/Command/_chflags
+++ b/Completion/BSD/Command/_chflags
@@ -1,65 +1,69 @@
#compdef chflags
-local flags args own='-g *(-u$EUID)'
+local args flag_descs flags 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' \
+flag_descs=(
+ uappnd 'user append-only'
uchg 'user immutable'
+)
if (( ! EUID )); then
- addflags \
- arch archived \
- nodump nodump \
- sappnd 'system append-only' \
+ flag_descs+=(
+ arch archived
+ nodump nodump
+ sappnd 'system append-only'
schg 'system immutable'
+ )
unset own
fi
if [[ $OSTYPE = (darwin|dragonfly|freebsd|netbsd)* ]]; then
- addflags opaque opaque
+ flag_descs+=(opaque opaque)
if [[ $OSTYPE = darwin* ]]; then
- addflags hidden hidden
+ flag_descs+=(hidden hidden)
fi
if [[ $OSTYPE = (dragonfly|freebsd)* ]]; then
- addflags uunlnk 'user undeletable'
- (( EUID )) || addflags sunlnk 'system undeletable'
+ flag_descs+=(uunlnk 'user undeletable')
+ (( EUID )) || flag_descs+=(sunlnk 'system undeletable')
fi
[[ $OSTYPE = dragonflybsd* ]] && {
- addflags \
- cache XXX \
+ flag_descs+=(
+ cache XXX
nouhistory 'user nohistory'
+ )
- (( EUID )) || addflags \
- noscache XXX \
+ (( EUID )) || flag_descs+=(
+ 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' \
+ [[ $OSTYPE = freebsd* ]] && flag_descs+=(
+ 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
+() {
+ 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
+} $flag_descs
+
if [[ $OSTYPE = (darwin|dragonfly|freebsd)* ]]; then
args=(
"-f[don't display diagnostic messages]"
@@ -68,12 +72,12 @@ if [[ $OSTYPE = (darwin|dragonfly|freebsd)* ]]; then
fi
_arguments -s -A "-*" : $args \
+ ':file flag:_values -s , "file flags" $flags[@]' \
+ '*:file:_files "$own"' \
- 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)]' \
- ':file flag:_values -s , "file flags" $flags[@]' \
- '*:file:_files "$own"'
+ '(-L -H)-P[do not follow symlinks (specify with -R)]'