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 2781 invoked from network); 21 Mar 2021 13:02:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Mar 2021 13:02:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1616331756; b=Az3GUKPxWy6ME0/6MoK4wAee2wr8hbyquvf9U8Sw0N52lqipVPX/OC4YWEB8E/IwHcevRJv5Ur R/Ui7PJfcs3/jF4KcyC9A69yA0E7A+mKUcVZCqSkpMgKhRICx3GC5ha4wAGYSklgdB9pMjwM7/ cMmotfiodt0BSTLMGhtZRAY6+XicF284g+HBuaoEhMlVQ7JTTFBZR5+7eoNEPHxCVw3C23LER2 zp3geK0LqxBIOxM/eYVkT4sDF5ttIPems4uLYjybk2UN4hv+n6JcPCYS+uoGmwdC5lGipSzIVJ /h6q7Pv+2MWYIZUFZvwrf+Jsv0lSM9lVgQz0q9wqhZ9Flg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mx.cs.msu.ru) smtp.remote-ip=188.44.42.42; 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=1616331756; bh=F6o1MnfqcQ6hiu5RVby/uma/RKr3jW39YXSs68akNJA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Subject:Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Cc:To:From:DKIM-Signature:DKIM-Signature; b=PqNS2EdwCREUQ6zkIFxM2RWMOC6dRWuwSLRm7yWI4xP9vPKv+N+cXa/rFvQG11wDTHKfJDwLCp +PWQg9wuuBVbhjwzWM597CR2aCnyq/pgvOs3QIjsgtCtdnlR6rWXXlNScvG2pKJEhEE4l6AVOI OgAUfIA1ztkoIiWJxsF418FK62m0GfTm3f/E6D3dEBPlX8aQSCrqpfkUPaeFnzpRheR406XYqf idu2V7LLszP9d9Zq0Q53L623j7cmCtZLUMPc/Yxmpo77LJLHH6R2j/vsLBJeQu0eiAju94mPk2 ONgIhMSKhJdguM7sMumuIaAEcuVeS+v9P47PCy6HufghRA==; 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:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Cc:To:From:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=WzJLl+q6pMina+g7BZszOCDhnwmubtyxmhfN1wqkMT8=; b=RQms4a5360ie3AnirFOWTep/rF ejcJXajU9JxHggh8KIvcwyYMjxmBxDd8UAQWJJRDhaOu5SgNe2GVVEIXnpxqnFdbYC9dmFMcFU9q/ V4RjxuVPqArgeLiypRNxEvU+grDbdso7hqBVqm7fpn/Ni0bYkYU9XHbr9oM+gqeOS9lNXCXDTmCCJ RAPi2BP57QhR3DHDZEnSDbpNsuKbcmXQHVI4Wro9Xcln8MezTermMOEM5ZeH76eH716iMF6FdxhsA aeVBKUWLqq77kmV07Nljz2mDnlPN5e7zeRH7fd/lQt8uVSpy79wCdAzZNbZqKaBncCvSH2+OsC4/K 7y6mWAcg==; Received: from authenticated user by zero.zsh.org with local id 1lNxj1-0003dF-SA; Sun, 21 Mar 2021 13:02:35 +0000 Authentication-Results: zsh.org; iprev=pass (mx.cs.msu.ru) smtp.remote-ip=188.44.42.42; 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 mx.cs.msu.ru ([188.44.42.42]:53612 helo=mail.cs.msu.ru) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lNxiL-0002xh-S9; Sun, 21 Mar 2021 13:01:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cs.msu.ru; s=dkim; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc: To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WzJLl+q6pMina+g7BZszOCDhnwmubtyxmhfN1wqkMT8=; b=JQj5mfKx/0X988IP4B7ZFW/0j/ J7WfmMy4j5xEHlODpmsCG6pRas318sPqKCMjAvFAT9+nOuv730Gx2h8vHoZ0ThUOmq0/1SBeUtlPv CYC48RXdcBYCU2yle1tVmhTUbc74FCiCejFBj5z/oJy35pIN0QoXQD/9M2NAqY7skvu//9nxLF92m 8Ca9qnZD18scf5pAl5cEz6+VHKLnHWnM/wyBkrNTy0/Z2IRAVNRR/KNxGwZud6Gi+q6DKplkDU31w sZiDq0VTkwm0p6ycdURh9kbiCvrTh62VYxDc1gBXOC/cgX71U7d7Oq4fc7/qr30uW11yM8W0qNxoI jT5deTOQ==; Received: from [37.204.119.143] (port=38992 helo=localhost.localdomain) by mail.cs.msu.ru with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lNxiL-00085B-2e; Sun, 21 Mar 2021 16:01:53 +0300 From: Arseny Maslennikov To: zsh-workers@zsh.org Cc: Arseny Maslennikov Date: Sun, 21 Mar 2021 16:01:29 +0300 Message-Id: <20210321130131.1667276-1-ar@cs.msu.ru> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 37.204.119.143 X-SA-Exim-Mail-From: ar@cs.msu.ru Subject: [PATCH v2 1/3] 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: 48212 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: This is intended for use on Linux-based systems only. The next patch introduces a completion for setpriv(1), which actively uses this function. I believe some utilities that handle caps may want to use it as well, albeit indirectly (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). --- Changes since v1: * _capability_names is no longer shipped; users are encouraged to use _capabilities with compadd options as a match provider. Completion/Linux/Type/_capabilities | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Completion/Linux/Type/_capabilities diff --git a/Completion/Linux/Type/_capabilities b/Completion/Linux/Type/_capabilities new file mode 100644 index 000000000..8cb31878f --- /dev/null +++ b/Completion/Linux/Type/_capabilities @@ -0,0 +1,65 @@ +#autoload + +# This function completes POSIX capabilities for Linux. +# Many command line utilities expect different syntax to encode various kinds +# of capability names or sets, so this function tries to be as generic as +# possible. It accepts compadd options to allow variations on the exact +# generated completion matches. +# +# Usage examples: +# +# Complete full capability names: +# _capabilities -p cap_ +# Sort the completion list by capability number: +# _capabilities -o nosort + +# 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:]]+CAP_//; s/[[:space:]]+[0-9]+$//' | tr '[[:upper:]]' '[[:lower:]]' +local -a caplist=( + chown + dac_override + dac_read_search + fowner + fsetid + kill + setgid + setuid + setpcap + linux_immutable + net_bind_service + net_broadcast + net_admin + net_raw + ipc_lock + ipc_owner + sys_module + sys_rawio + sys_chroot + sys_ptrace + sys_pacct + sys_admin + sys_boot + sys_nice + sys_resource + sys_time + sys_tty_config + mknod + lease + audit_write + audit_control + setfcap + mac_override + mac_admin + syslog + wake_alarm + block_suspend + audit_read + perfmon + bpf + checkpoint_restore +) +local -a expl + +_description capabilities expl "Linux capability" +compadd "${(@)expl}" "$@" -a - caplist -- 2.31.0