From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7921 invoked by alias); 7 Sep 2016 14:16:43 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39223 Received: (qmail 27065 invoked from network); 7 Sep 2016 14:16:43 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi0-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.218.46):SA:0(0.3/5.0):. Processed in 0.385082 secs); 07 Sep 2016 14:16:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_PASS,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: phy1729@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.218.46 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=IdeVGul8YRjsJ/KwI7kDMkpViaTCoxAKOh8oHQNeIH0=; b=CYtj9Zs1MFGGFC+C3wvMSb+q2HjhUfF51ocJYHrpaAoYxuwqqWxlvg7cNQL6+B+trA V+m4cz1BlZxJY/s/e/Y0DwOd1MGTA9SB4Kw4Sbt6LtANAeTHuUwt/nlVirKa//3v7q65 Xf+LUaW3tVxCgDGzzP0JQZH21sMUVyUVB8LFldp8K0bFZZ0R4xxxkDyhZb9tlKlzpeV4 5RieYjbnhLEowIhfKE/rnbmt34W7eUrAx/uxjshvhN68g64WW8/V2OB5xcy4phxIsjkK P/oVXpTFLxcJ+mK7j3GMFqpsy1k5GJiXOgVYoN4uEQIl/3+wycrtNXe2rl2Nctd823PE kCsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=IdeVGul8YRjsJ/KwI7kDMkpViaTCoxAKOh8oHQNeIH0=; b=KbPUMlYwJzXd71hN8nIZZElZ/JRkgoteb/vQ9onre1D0J+Nf7s0abNXDRfgr8+trUT YF3HgFDBsQwNl+FiaQnHfJWTprZfT7vkOMYqtmr+TLiA9CDrVgDh3LX9XpmdlrEfsdfP KBU37bJQI6JJ7/Zk2R/RLY+Xz/iRGgkzKl3s45TDNvPDPg8g9fHwqRZZJ3xqeh9XZBvw vcG9a9VgTHDx1+uo3DBMb1bWMcm8xk2FXAv/I36NI1hlqHZK1dc4R16Fvpw1fs5MVXoG h/E9m/y0JBbnYD6CHc0gXl4UpSm6bPYuYkh+3c/8q8veCTY2AvePIk+OXPubqcN+CfL0 zLmA== X-Gm-Message-State: AE9vXwOUXENlZvol5WBaYDn4dPQ+zF50YBtbp9g+78Zmy7Ee5RoCb9LY/gMuYAJEkqha6g== X-Received: by 10.202.219.135 with SMTP id s129mr36697260oig.123.1473230740462; Tue, 06 Sep 2016 23:45:40 -0700 (PDT) Date: Tue, 6 Sep 2016 22:58:59 -0500 From: Matthew Martin To: zsh-workers@zsh.org Subject: [patch 1/3] _chflags: Introduce addflags to reduce redundancy Message-ID: <20160907035858.gqskctjfq4el2skh@CptOrmolo.darkstar> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20160827 () 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]'