zsh-workers
 help / color / mirror / code / Atom feed
* [patch 1/3] _chflags: Introduce addflags to reduce redundancy
@ 2016-09-07 12:40 Matthew Martin
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Martin @ 2016-09-07 12:40 UTC (permalink / raw)
  To: zsh-workers

This seems to not have gone through.

Mostly functionally the same but
- s/attribute/flag/ the description of offline, sparse, and reparse
- correct the negation for offline, rdonly, sparse, system, and reparse
- remove the non-existant unlnk flag

- Matthew Martin

diff --git a/Completion/BSD/Command/_chflags b/Completion/BSD/Command/_chflags
index bfbaa01..8147df0 100644
--- a/Completion/BSD/Command/_chflags
+++ b/Completion/BSD/Command/_chflags
@@ -2,55 +2,46 @@
 
 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]'
-)
+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 \
+  nodump nodump \
+  opaque opaque \
+  uappnd 'user append-only' \
+  uchg 'user immutable'
 
 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]'
-  )
+  addflags \
+    arch archived \
+    sappnd 'system append-only' \
+    schg 'system immutable'
   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]'
-  )
+  addflags \
+    hidden hidden \
+    uunlnk 'user undeletable'
+
+  [[ $OSTYPE = freebsd* ]] && addflags \
+    offline offline \
+    rdonly readonly \
+    reparse 'Windows reparse point' \
+    sparse 'sparse file' \
+    system system
+
+  (( EUID )) || addflags sunlnk 'system undeletable'
 
-  (( 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]'


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [patch 1/3] _chflags: Introduce addflags to reduce redundancy
@ 2016-09-07  3:58 Matthew Martin
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Martin @ 2016-09-07  3:58 UTC (permalink / raw)
  To: zsh-workers

Mostly functionally the same but
- s/attribute/flag/ the description of offline, sparse, and reparse
- correct the negation for offline, rdonly, sparse, system, and reparse
- remove the non-existant unlnk flag

- Matthew Martin

diff --git a/Completion/BSD/Command/_chflags b/Completion/BSD/Command/_chflags
index bfbaa01..8147df0 100644
--- a/Completion/BSD/Command/_chflags
+++ b/Completion/BSD/Command/_chflags
@@ -2,55 +2,46 @@
 
 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]'
-)
+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 \
+  nodump nodump \
+  opaque opaque \
+  uappnd 'user append-only' \
+  uchg 'user immutable'
 
 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]'
-  )
+  addflags \
+    arch archived \
+    sappnd 'system append-only' \
+    schg 'system immutable'
   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]'
-  )
+  addflags \
+    hidden hidden \
+    uunlnk 'user undeletable'
+
+  [[ $OSTYPE = freebsd* ]] && addflags \
+    offline offline \
+    rdonly readonly \
+    reparse 'Windows reparse point' \
+    sparse 'sparse file' \
+    system system
+
+  (( EUID )) || addflags sunlnk 'system undeletable'
 
-  (( 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]'


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-07 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07 12:40 [patch 1/3] _chflags: Introduce addflags to reduce redundancy Matthew Martin
  -- strict thread matches above, loose matches on Subject: below --
2016-09-07  3:58 Matthew Martin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).