From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: Zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: update ansible completion to 2.9
Date: Fri, 10 Jul 2020 23:59:31 +0000 [thread overview]
Message-ID: <20200710235931.4dc2878b@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <77655-1594207879.361279@1ICO.q8MP.Dgdc>
Oliver Kiddle wrote on Wed, 08 Jul 2020 13:31 +0200:
> For 2.9.10 to be precise but I don't think much changes in the minor
> patch releases.
> Most of the changes appear to be with ansible-galaxy and ansible-vault,
> neither of which I use so much. Completing tags is new. Unfortunately
> the playbook tends to come last on the command-line after you've
> specified the tags so it isn't really possible to get the exact playbook
> and parse it for includes and roles. But completion for tags is too
> useful to leave out completely.
>
> Oliver
>
> +++ b/Completion/Unix/Command/_ansible
> @@ -232,27 +231,68 @@ case $state in
> + tags)
> + # The recursive glob here is questionable and perhaps there should be a style.
> + _sequence _wanted tags expl tag compadd - \
> + ${(s.,.)${(j.,.)${(M)${(f)"$(cat **/*.yml)"}:# #tags:*}#*: }} && ret=0
> + ;;
Review of this block:
1. Missing end-of-options guard
2. Agree that recursive glob is questionable. It's effectively
unbounded work, to say nothing of NFS mounts, /zfs/.snapshot/ dirs, and
the like. I'm not sure that should be the default behaviour. One
alternative suggestion is a zstyle whose value is a list of files to
grep. Another POV: if the yml files are in version control, then the
VCS could be queried (e.g., `git ls-tree -r ./`). That might be useful
in other completions too.
3. Add the (N) glob qualifier?
4. As written, this slurps "$(cat **/*.yml)" into a giant string
literal, then splits it into an array in memory, etc.. I suspect it
would be a lot faster to just use grep(1) or sed(1), since we're
forking anyway.
Haven't had time to review blocks other than this one, sorry. (Might
do so later if I have time, but don't wait for me.)
Cheers,
Daniel
prev parent reply other threads:[~2020-07-11 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <77655-1594207879.361279.ref@1ICO.q8MP.Dgdc>
2020-07-08 11:31 ` Oliver Kiddle
2020-07-10 23:59 ` Daniel Shahaf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200710235931.4dc2878b@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=okiddle@yahoo.co.uk \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).