From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: PATCH: Improve quote handling in _ant completion
Date: Sun, 3 Dec 2023 16:05:09 -0800 [thread overview]
Message-ID: <CAH+w=7Z+y2WXsaxdeucOYJ5cd3y4b-1VstR8OSv8x5Q_guQDxQ@mail.gmail.com> (raw)
In-Reply-To: <27223-1701637728.078257@Bkhc.Hp7M.X2jV>
[-- Attachment #1: Type: text/plain, Size: 722 bytes --]
On Sun, Dec 3, 2023 at 1:08 PM Oliver Kiddle <opk@zsh.org> wrote:
>
> It definitely would be best renamed with _ant_ as a prefix. I would just
> call it _ant_targets and include the compadd line in the function.
That last is a little tricky because it calls itself recursively.
> Perhaps whoever wrote it wanted to use it outside of completion.
Heh.
> It could also be rewritten to use fewer subshells.
I'm not certain enough of what's going on in there to try to do that.
One subshell is just to protect the parent against a "cd", the others
probably tail-exec themselves except for the one that has an "echo
$file | sed".
Rewritten to avoid "sed" you mean? The s/// are mostly pretty gnarly.
[-- Attachment #2: more-_ant.txt --]
[-- Type: text/plain, Size: 1550 bytes --]
diff --git a/Completion/Unix/Command/_ant b/Completion/Unix/Command/_ant
index 91428b854..e5bfe7cf9 100644
--- a/Completion/Unix/Command/_ant
+++ b/Completion/Unix/Command/_ant
@@ -6,7 +6,8 @@ local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args
local buildfile classpath cp userjars importedfiles target='*:target:->target' targets tmp
-find_targets() {
+(( $+functions[_ant_targets] )) ||
+_ant_targets() {
importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $1) )
# Tweaked to omit targets beginning with "-" that can't
# be invoked from the command line; see zsh-workers/24129.
@@ -14,12 +15,12 @@ find_targets() {
if (( $#importedfiles )) ; then
( cd $1:h
for file in $importedfiles ; do
- expanded=( $(echo $file | sed -n "s|\${ant.home}|$ANT_HOME|p") )
- if [[ ! "bla$expanded" = "bla" ]]; then
+ expanded=${file//\${ant.home}/$ANT_HOME}
+ if [[ $expanded" != "$file" ]]; then
file=$expanded
fi
if [[ -f $file ]]; then
- find_targets $file
+ _ant_targets $file
fi
done )
fi
@@ -135,7 +136,7 @@ case $state in
)//$'\015'}"
_describe 'target' tmp && ret=0
else
- targets=( $(find_targets $buildfile) )
+ targets=( $(_ant_targets $buildfile) )
_wanted targets expl target compadd -a targets && ret=0
fi
else
next prev parent reply other threads:[~2023-12-04 0:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <207461559.9336309.1701221332233.ref@mail.yahoo.com>
2023-11-29 1:28 ` German Riano
2023-11-29 19:18 ` Bart Schaefer
2023-11-29 19:19 ` Bart Schaefer
2023-11-29 19:56 ` Mikael Magnusson
2023-11-29 23:44 ` Bart Schaefer
2023-11-30 0:15 ` German Riano
2023-11-30 0:52 ` Bart Schaefer
2023-11-30 1:28 ` German Riano
2023-11-30 2:40 ` Bart Schaefer
2023-12-01 19:20 ` German Riano
2023-12-02 23:21 ` Bart Schaefer
2023-12-02 23:31 ` Bart Schaefer
2023-12-03 21:08 ` Oliver Kiddle
2023-12-04 0:05 ` Bart Schaefer [this message]
2023-12-04 0:11 ` Bart Schaefer
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='CAH+w=7Z+y2WXsaxdeucOYJ5cd3y4b-1VstR8OSv8x5Q_guQDxQ@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--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).