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=-2.2 required=5.0 tests=DKIM_ADSP_ALL,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8655 invoked from network); 26 Feb 2021 17:02:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Feb 2021 17:02:16 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614358936; b=QR0bUEsVXLvZFkJ+zQqxlyVJNMukk8pKCNkGB0lS26jk2AOZwkJ3LWTtIRQFlMItC/KnUIvd8x D/nmiPZ3s8bZ16CkRzf3WbKz2Qttpf8et4SQFp6Kfvjn3aLdcfIz1HYPN8KpR+b45C5QIFQEVV BQzG9M/A83PBSBdAmqTfgWQpQHsDkzdcMqi2Zm9Id0AIBylMEnbEu+IieIuQ+wBye6BguxYvWI bmz6bj+Bxl21OKjE2MoDYIvQ7ZVXT3Sy/IB19h5Gm0P7q6gPDj/jDGZxIJcvBiLH/0dDtBRcrI soa8Y+BoKs+zFL+1TaCeJJw5uiK9VfZm0Q6LGbLYAazAog==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail.cs.msu.ru) smtp.remote-ip=188.44.42.39; dkim=pass header.d=cs.msu.ru header.s=dkim header.a=rsa-sha256; dmarc=pass header.from=cs.msu.ru; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1614358936; bh=190tbARKWU201Uwp4yHmtoWk7N5n/LX+8x2FfhAQkHU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Subject:In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Cc:To:From:Date:DKIM-Signature:DKIM-Signature; b=EFMpOIVPIO77HVijlZmqVdUTiJAW1PWJ0dovW5ZBqwpH9tJiMR/GGYHGT3QuX+EJK0OJ9nZgTo sNIYrPfHJ+2wG1cwxYIpU1p6GA3Igm8hIjR5xMdhCdLha3bg/aTHug6TL35r8cm0RS3W+V3aAX CbS3xlGHUZR7+bZhfF3Qb2ZqV6ABBYTF91UMRLF7l4x1AthsUmY5j9MBpW8smo+0FMmXfizxux RYTZ6/jb/hjJo5Nd3KcyHWKZ3VUCA/5oPqPsCV2hwecdI7qXP3p9A/kw3rAUNxXhp6FCEkTSqu O6jT0vn1ljKCCZ+f9w2b3c1Vqa3fgIxQj3vzOs6q7uF53Q==; 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:Subject:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=pZPitzLH7iQrYK0uWsS37YJGGTars9og7az+1OvOqQQ=; b=z5h+qFmsapbmHvUZCNgLNqdpZQ ylV8vLVm09oigO7MSoF9pv+JfIuoxepdDQbpKb5oTLUHuqRxHrAOOORxu1QfwoRqSq7GENs4qf8AE PIRSfFR/YqFVeltgixlBDNJvBUVIHn9aiY1xuSbyeYMrRKaBjff6MrX2MgxbSGHVQV69M5P4AKlCg Wwe5ZIpMbRBN4/0sCTMnfQCpMwJgRYZMYV/5rbMdX6MuqXPGL1Ef/MSAYfEkmfQF9VF0NcE25K8hN U6qyRMFa3u5ecsTuhT9BQ9hhjBdEyMp0vkMl4MlDLFtGleX107Fhf8LOVHFNoe2fHLVbf5g5xkg8n gQXwolVw==; Received: from authenticated user by zero.zsh.org with local id 1lFgVK-000LVM-8g; Fri, 26 Feb 2021 17:02:14 +0000 Authentication-Results: zsh.org; iprev=pass (mail.cs.msu.ru) smtp.remote-ip=188.44.42.39; dkim=pass header.d=cs.msu.ru header.s=dkim header.a=rsa-sha256; dmarc=pass header.from=cs.msu.ru; arc=none Received: from mail.cs.msu.ru ([188.44.42.39]:44381) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lFgUy-000LLz-M4; Fri, 26 Feb 2021 17:01:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cs.msu.ru; s=dkim; h=Subject:In-Reply-To:Content-Type:MIME-Version:References:Message-ID :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pZPitzLH7iQrYK0uWsS37YJGGTars9og7az+1OvOqQQ=; b=jbwwLmgV8xXZIUsKTQyU4YhyqL 4A3vMEfp/gkAFrOCcUJt3bGMCZZNJcXh4n0Fbwy2UnePCPaNHsa84t94ze6jxWmVz48V5a+7tLHgG qMCnOm4i2CtNE3hWKXvr/Tev71U4qsWGL1DkVQTBD4BFVBeimtsw9+MKpe0q37s4u95cbBiXoEoAP 1crgS0Jlk4a3uz11skFtyB78IjBi1i/glVDOvB9E9svQEw91qafDVrWH9V/8moPmULcSA1v63QPiw 9Z+lbiREu4pLhK+ACvlPah57EMIUEY5Q/E8CZ7B9qxk7m1sY5cunJMZsHmE9MH8Wkdid0ICKm5ES0 VPaZwuig==; Received: from [37.204.119.143] (port=50234 helo=cello) by mail.cs.msu.ru with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lFgUw-0002cq-F4; Fri, 26 Feb 2021 20:01:50 +0300 Date: Fri, 26 Feb 2021 20:01:44 +0300 From: Arseny Maslennikov To: Daniel Shahaf Cc: zsh-workers@zsh.org Message-ID: References: <20210226075558.883716-1-ar@cs.msu.ru> <20210226155018.GF13554@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="S3paHzlVVTIdM0T/" Content-Disposition: inline In-Reply-To: <20210226155018.GF13554@tarpaulin.shahaf.local2> OpenPGP: url=http://grep.cs.msu.ru/~ar/pgp-key.asc X-SA-Exim-Connect-IP: 37.204.119.143 X-SA-Exim-Mail-From: ar@cs.msu.ru Subject: Re: [PATCH 1/2] Introduce new completion for Linux task capabilities X-SA-Exim-Version: 4.2.1 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) X-Seq: 48120 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: --S3paHzlVVTIdM0T/ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 26, 2021 at 03:50:18PM +0000, Daniel Shahaf wrote: > 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, >=20 > (The difference is _capability_names just returns the names in an > array, while _capabilities actually adds them as completions.) >=20 > > 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), >=20 > 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, =C2=ABcompadd -P=C2=BB, et al.. Do you mean invoking =C2=AB_capabilities -O array_name=C2=BB to pass the -O= to compadd, and then using the array_name in _setpriv and possible future users? As far as I understand, in that case _capabilities will have to avoid looping over tag labels, i. e. calling _wanted, as it does now. >=20 > 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. I'm likely not ready to write one just yet, but I agree. >=20 > To be clear, I'm not asking for anything to be changed. (Others might, > of course.) >=20 > > and if not yet =E2=80=94 it is still available to be manually compdeffe= d. >=20 > So you pronounce "compdef" with the stress on the second syllable? Yes, I do. Never had the chance to hear the word in oral speech, though. :) Come to think of it, considering the "comp" prefix is quite common in our completion system, it doesn't make a lot of sense to stress "comp". >=20 > > +++ b/Completion/Linux/Type/_capabilities > > @@ -0,0 +1,10 @@ > > +#autoload > > + > > +if [[ $OSTYPE !=3D linux* ]]; then > > + _default; return > > +fi >=20 > 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 =C2= =ABssh > $linuxbox foo --with-capability=3D=C2=BB. I intended to play nice in case unrelated "capabilities" are present (or introduced later) on those OSTYPE's and pulled Oliver's trick from the recently posted _unshare. There might be a better way to do it; I'm open to discussion. >=20 > > +++ 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/ca= pability.h > > + # and subject to the following pipe filter: > > + # grep 'define CAP' | sed -r 's/^[[:space:]]*#define[[:space:]]+//; = s/[[:space:]]+[0-9]+$//' | tr '[[:upper:]]' '[[:lower:]]' A nitpick to myself: For simplicity I did not mention that this filter still appends between 3 a= nd 6 lines to the desired output; they are of technical value and of no use to us since they do not contain cap names, and can be stripped manually. > > + local -a C=3D( >=20 > Please use a longer, meaningful variable name. OK. >=20 > > + cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fset= id cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_b= ind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ip= c_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 c= ap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_blo= ck_suspend cap_audit_read cap_perfmon cap_bpf cap_checkpoint_restore >=20 > Suggest to list these one per line, because: >=20 > - Some interfaces (e.g., https://github.com/zsh-users/zsh/) support > line-based blame but not word-based blame (`git log -S`). >=20 > - If capabilities are ever removed, the diff removing them would be > clearer. >=20 > In terms of the filter, that's just =C2=AB| xargs -n1=C2=BB. I'd personally like them being listed one per line, too. Will do. >=20 > > + ) > > + set -A "$1" "${(@)C}" >=20 > Handle the case that no arguments were passed=C2=A0=E2=80=94 e.g., by doi= ng ${1:-reply}. OK. >=20 > I'll leave reviewing 2/2 to someone else. Ok; I'm going to send a revised series once 2/2 is reviewed in case there are any problems with it. >=20 > Thanks for the patch, >=20 > Daniel --S3paHzlVVTIdM0T/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE56JD3UKTLEu/ddrm9dQjyAYL01AFAmA5KXIACgkQ9dQjyAYL 01Cj7Q/+PFopUVghnpWAmUSE8m8fm2RZbMr+rjNor1h4m24J/g38JUmg+NUvEhns o1PRXHDwYCVOT3G9wKKeO5eObMdlYaap1UItiuUrTKMhDC0NC+iLPMfJ0jvGg9c8 YvwGKbXQGg+ou6EjQZBeH2GL6mGO5VcH0pxifHn5ZseS5ZzFzysr2o2411cBDhL3 FQ1qqy+zuTEireyBGz1RsZ+Pc8JlfEvzHu1UNgv446xxL/lQ+RdFQgg4D49baASZ l90Txz6+JnwkhONdjWbzmFAcAORvxCS8eVXtnyNmD7JRQt/Qc7RY2nMp2u1bfdxD 4Xtu2zI9+g5WoVyRZSanix2taSPSW6lZHXpDclT/f/V0Zf6NbAjSpEgSCKDFQUNk cIe8/gbA2KY5JUyUHHSqXD0/v0mzP5mCbScJLdNMLxbcKKUv3cP060CJB5BJC6Qm fScW/r2CgcXsc3ZB3tpuutfWd6zdy+UvRSaRRhrbr4bxOBh+jxGrsoLeFsOAQfD3 zM8EQXpAGbKNafZ8x++qNdsButkPH4bNHpqz6c/fy+p9a4sPi1Ti3fpOVfLhiyCL H3nXqbOaTpaPFPBsbAKQU1tf3EPSk9BGSSF14TX86QcVWmBZ4U7JUTZ+oz3MqXFE HHa1r456O14TEjnbVrJSulrvfY28G1K1Pm3IrSNkmnjBWYVJD3Q= =caqw -----END PGP SIGNATURE----- --S3paHzlVVTIdM0T/--