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=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20525 invoked from network); 4 Jun 2020 02:28:02 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 4 Jun 2020 02:28:02 -0000 Received: (qmail 25387 invoked by alias); 4 Jun 2020 02:27:54 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24900 Received: (qmail 8989 invoked by uid 1010); 4 Jun 2020 02:27:54 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25828. spamassassin: 3.4.4. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 0.764278 secs); 04 Jun 2020 02:27:54 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudegtddgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfgjfhfogggtgfesthhqtddtredtjeenucfhrhhomhepffgrnhhi vghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvgeqne cuggftrfgrthhtvghrnhephfdtteefheevuedthedutdeifeegteettdejtdffheduieei jeelteetkeduteehnecukfhppeejledrudejiedrfeelrdeileenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhh rghhrghfrdhnrghmvg X-ME-Proxy: Date: Thu, 4 Jun 2020 02:27:14 +0000 From: Daniel Shahaf To: Paul Ruane Cc: zsh-users@zsh.org Subject: Re: Cryptsetup completion Message-ID: <20200604022714.5d255f20@tarpaulin.shahaf.local2> In-Reply-To: References: <20200603005555.304cca04@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Paul Ruane wrote on Wed, 03 Jun 2020 13:52 +0100: > On Wed, 3 Jun 2020 at 01:56, Daniel Shahaf wrote: >=20 > > The helper functions are in the global namespace so they should have > > names that are less likely to clash. Also, they aren't specific to > > cryptsetup, so we could break them out to separate, autoloadable files = =20 >=20 > I have renamed these with prefix "_crypto". I noticed commands and > types are now split into their respective directories so I have placed > them accordingly. They've always been split, but there's a configure option to combine them at installation time. (That's one of several reasons to base patches on git master.) > > that (you can simply clone the git repository and, for testing, set > > =C2=ABfpath=3D( /path/to/zsh/Completions/**/*(/) )=C2=BB prior to runni= ng compinit.). =20 >=20 > I was unable to get the fpath with the globbing to work. I ended up > using "fpath=3D( /home/paul/projects/zsh/Completion )". Right, you do need Completion/ there, and what I wrote above won't do that. Sorry about that. (I based that glob on the $ZDOTDIR/.zshenv I use for development, but reduced it too much.) > Even so I had some errors ("_arguments:comparguments:393: too many > arguments") completing with many commands, not just cryptsetup, but I > assume that this is some incompatibility between my 5.8 and HEAD. Yes, that's correct: _arguments is coupled to the C implementation of the "compargumetns" builtin. Sorry again; I'd forgotten about that. (To use 5.8 binaries with master's _arguments, the third argument in calls to =C2=ABcomparguments -W=C2=BB needs to be removed.) > I've used a slightly modified version of Mikael's parameter expansion > to eliminate the need to fork processes. >=20 > The new patch--in correct format :)--is here: >=20 > diff --git a/Completion/Linux/Command/_cryptsetup > b/Completion/Linux/Command/_cryptsetup Your MUA inserted hard line breaks in the patch, which corrupted it. For future reference, either configure your MUA not to wrap line breaks and not to strip trailing spaces, or send patches as an attachment named *.txt [that's the most portable way to ensure a texty MIME type, which helps recipients' MUAs]. > +++ b/Completion/Linux/Type/_crypto_ciphers > @@ -0,0 +1,7 @@ > +#autoload > + > +cipher_list=3D( ${${${(M)${(s:name:)${(M)${(f)"$( cipher*}#*: }%% *} ) =20 This variable is set globally. It should be declared local (=C2=ABtypeset = -a=C2=BB). On my system the array has several elements with the value "aes" (as well as one "__aes"). Is that intentional? If not, adding -U to the array declaration will squash duplicates. > +_describe -t ciphers 'cipher' cipher_list > + > +return ret There's no variable =C2=ABret=C2=BB in this function. However, the call to _describe is in any case the last thing in the function, so it'll be easier to delete this line entirely. Paul Ruane wrote on Wed, 03 Jun 2020 13:52 +0100: > +++ b/Completion/Linux/Command/_cryptsetup > @@ -8,8 +8,8 @@ _arguments -s \ > - '(-c --cipher)'{-c+,--cipher=3D}'[set cipher]:cipher specification' \ > - '(-h --hash)'{-h+,--hash=3D}'[hash algorithm]:hash algorithm' \ > + '(-c --cipher)'{-c+,--cipher=3D}'[set cipher]:cipher specification:_cr= ypto_ciphers' \ > + '(-h --hash)'{-h+,--hash=3D}'[hash algorithm]:hash algorithm:_crypto_h= ashes' \ > +++ b/Completion/Linux/Type/_crypto_ciphers > @@ -0,0 +1,7 @@ > +cipher_list=3D( ${${${(M)${(s:name:)${(M)${(f)"$( +++ b/Completion/Linux/Type/_crypto_hashes > @@ -0,0 +1,7 @@ > +hash_list=3D( ${${${(M)${(s:name:)${(M)${(f)"$( > > NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES > > > The available combinations of ciphers, modes, hashes and key s= izes > > > depend on kernel support. See /proc/crypto for a list of avail= able > > > options. You might need to load additional kernel crypto modul= es in > > > order to get more options. > > >=20 > > > For the --hash option, if the crypto backend is libgcrypt, the= n all > > > algorithms supported by the gcrypt library are available. For= other > > > crypto backends, some algorithms may be missing. So, two questions: - Are there 'shash' entries in /proc/crypto that _shouldn't_ be offered as completions? - Are there hash algorithms that would be accepted as arguments to the -h option that aren't listed in /proc/crypto? Cheers, Daniel