From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 750 invoked from network); 26 Feb 2021 15:50:49 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Feb 2021 15:50:49 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614354649; b=KUsHJXx6PO1Qs7jwFJua6/lkIenxq25kikn4bzkAODWQ3c07ubqOcctS3V1L/09GPXSZH/laPr 6zOipocH1fcShn5/tQYUVwYy5w7u2d3SqFIZ+8Am0pK7BVqyPBgRT+vvj77AOCfHvdUcmaVzJ0 3SfIdITF1XJiEyfRMEfCEUltAhKasJc3s9lFtkMQ6ClxelVvo+JugaiX75cnzI11yp2P8XCZXb PIO38nIhbrB1ZQKUD41o54UpcCF4NYZ7lsVgMmWlu/BvvPdJPdmQJxA4sMl+4XXFmKfcDfrT8j Y4Qc2YcgGutj7SSK9FUbqBGGRZgzGtso33G96nnQaY3RgA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1614354649; bh=KULrtp0ucNDIDy4GlQQyV1nOO1pxrTGwhhicjGZNC9M=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=d1GCT+t8sJnuMoWosUVvMoOSmK+WK4HDLXKBSQtk2FEC9S6XP93//38s7lqmtqKGFvPLd8lw4J MqHDmG6ehARtxtDjIpseQ6yOS4741eGjzVwN26DOuFePdEtF5nDHcW4aRYPWMqzVGLne/zwjF4 LLf027WhbV2bPpwwryb/Pij2f5Zxm6jBtK7OMYH03PAi9rGQ8EQKEPV6A1mJnhY+Xje7+qFUqP tqesJpeSBkAE2ulgDElnZc6e30PRG+wRYdy5yrIlSEC/2nSmPS7imcEKTEsODUDPbFYp6Zlsxu dWv9HBwC40t6pLPBRWUw8b3bOK69G9XjEBa45XboD6oEpg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=QjDdA5aRH1zns6dU8j/beZE2mWHPvzRLvuBDAiNl4tE=; b=MXiMzHoq3kqQASiZl+SnizaRM3 i4mjfFPmgLTfF7jYoQI4xLF/6oEacSaVVpPNHgUB+XsHkWv22yX2f470SrJhlbcrtEK7ILnv4MnKB /FkY2tFzyrB8l03uK4j/izYt6SFPALhrdk4svqjmZb4YRAmwwNVeQNL3K0oE9dBWJxlwJnD/OcMxA 9zgj5ulBcpNCQBCUCCeGdnECDkTSqaIDlEtWASR3TjA6kKqpb9oalnZC2MQ8qceucQsgxOzjL5Jdq jZnpVxIyleCg+Zx5BboYxcRfWOV/1+OPILr86zVgffSRSTfAAPDkpcl1MsnCzUNzUr6wzSAsfWd8I OKP9bhOQ==; Received: from authenticated user by zero.zsh.org with local id 1lFfOA-000Jbk-MU; Fri, 26 Feb 2021 15:50:46 +0000 Authentication-Results: zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:56587) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lFfNp-000JRq-TX; Fri, 26 Feb 2021 15:50:28 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 3DB23C79; Fri, 26 Feb 2021 10:50:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 26 Feb 2021 10:50:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm2; bh=QjDdA5aRH1zns6dU8j/beZE2mWHPvzRLvuBDAiNl 4tE=; b=NEc0EpNKmS8mJjh4jeuxC8AJaYtlhHFSzkLmFWnDSBZSOUMYHqDADiPc olV17jwM4qDAPaamK3rLQbJbTyQy+VNhnjkLt5pSRX+K9dSaNMgFGnKZdsj4YPWT 70lB/UjabUY3Z/+d6ah7ojWtBJmH175IFy0WwUpZP1+Pcw8YwR/XtDKGWwWiYWjN Ce0ut/eU3ICnXhrcFjR68+mZdA6k5l/mjiONSi4BY+MEZEYvs03ojO1XnsG5KI+Y OABInXShbEJo7oO2UolNjdKi256zfEZVK573yUhGOZ/VHZe5cflriqAd5F7oCsYX j4hR7VpGuf9xh8e8Z9qdbE8i6UEqBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=QjDdA5aRH1zns6dU8j/beZE2mWHPvzRLvuBDAiNl4 tE=; b=ooYzTxDFIJRNYbHmhxBt58lgFYEL2qiLig00e5vPPjPIIyS3+62pst4AY IVUKrE9LZ9HRAfIGrXYb/By7tDwzMhDvECUfTtPdxdj5mIhMESNc7jfXuWO+OX8c HONzu19B2u/pleMTlKBg3NgKaeujCT/mBDnaW+EvP8HdrgBCjoXPwRX4QuCOwTm7 VnfpKxCsjxv+VGR0s80b3ZJ+wTkM2B9bE52pp5iP7shHz5Bt0S7xchqJvuoyZNEc YEEjISiAfaUf7ezd53G5lptupFGcl1UTA+w5Qjif78NfNFuhuF97vURnv7mEdgsF 4wMpFBaZ+BJX+wQM3aUUYgPcU4qKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrledugdekfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfsehtke dttddtreejnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeduudefleelgeffhe evgeevfefghefhuefhheffleejudduueehtdffgeeivdfgheenucffohhmrghinhepghhi thhhuhgsrdgtohhmnecukfhppeejledrudejledrheelrdduvddtnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhs hhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-179-59-120.red.bezeqint.net [79.179.59.120]) by mail.messagingengine.com (Postfix) with ESMTPA id 6BFF824005B; Fri, 26 Feb 2021 10:50:21 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4DnDd61Vrxzxg; Fri, 26 Feb 2021 15:50:18 +0000 (UTC) Date: Fri, 26 Feb 2021 15:50:18 +0000 From: Daniel Shahaf To: Arseny Maslennikov Cc: zsh-workers@zsh.org Subject: Re: [PATCH 1/2] Introduce new completion for Linux task capabilities Message-ID: <20210226155018.GF13554@tarpaulin.shahaf.local2> References: <20210226075558.883716-1-ar@cs.msu.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210226075558.883716-1-ar@cs.msu.ru> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48119 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Arseny Maslennikov wrote on Fri, Feb 26, 2021 at 10:55:57 +0300: > The next patch introduces a completion for setpriv(1), which actively > uses _capability_names. As for _capabilities, (The difference is _capability_names just returns the names in an array, while _capabilities actually adds them as completions.) > there are currently no > users of this function, but I believe some utilities that handle caps > may actually want to use it (neither setpriv(1) nor setcap/getcap(8), > for instance, want to offer the cap names themselves as completion > results; instead they want to prefix each name or a comma-separated > sequence of names), FWIW, I think it may well be possible to write _setpriv in terms of _capabilities as a black box, using some combination of _sequence, matchspecs, «compadd -P», et al.. As to setcap(8), it uses cap_from_text(3), which is a more elaborate format that presumably deserves its own completion function, to be used by any tool that uses that library function. To be clear, I'm not asking for anything to be changed. (Others might, of course.) > and if not yet — it is still available to be manually compdeffed. So you pronounce "compdef" with the stress on the second syllable? > +++ b/Completion/Linux/Type/_capabilities > @@ -0,0 +1,10 @@ > +#autoload > + > +if [[ $OSTYPE != linux* ]]; then > + _default; return > +fi Why? The code doesn't use /proc or /sbin/some-linux-only-tool, and having this guard prevents people on other OSTYPE's from completing «ssh $linuxbox foo --with-capability=». > +++ b/Completion/Linux/Type/_capability_names > @@ -0,0 +1,20 @@ > +#autoload > + > +_capability_names() { > + # Stores an array of Linux task capability names under a parameter > + # named by the first argument. > + > + # The list of Linux capabilities is taken from include/uapi/linux/capability.h > + # and subject to the following pipe filter: > + # grep 'define CAP' | sed -r 's/^[[:space:]]*#define[[:space:]]+//; s/[[:space:]]+[0-9]+$//' | tr '[[:upper:]]' '[[:lower:]]' > + local -a C=( Please use a longer, meaningful variable name. > + cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_mknod cap_lease cap_audit_write cap_audit_control cap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_block_suspend cap_audit_read cap_perfmon cap_bpf cap_checkpoint_restore Suggest to list these one per line, because: - Some interfaces (e.g., https://github.com/zsh-users/zsh/) support line-based blame but not word-based blame (`git log -S`). - If capabilities are ever removed, the diff removing them would be clearer. In terms of the filter, that's just «| xargs -n1». > + ) > + set -A "$1" "${(@)C}" Handle the case that no arguments were passed — e.g., by doing ${1:-reply}. I'll leave reviewing 2/2 to someone else. Thanks for the patch, Daniel > +} > + > +_capability_names "$@" > -- > 2.30.1 > >