zsh-workers
 help / color / mirror / code / Atom feed
From: Shohei Yoshida <syohex@gmail.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Fix gradlew completion
Date: Sat, 23 Sep 2023 12:13:36 +0900	[thread overview]
Message-ID: <CAFX6MOMN5oUhAAXJ+WSB6T8sOf5x8=Epejkv3XUxTEfJbUY1nQ@mail.gmail.com> (raw)
In-Reply-To: <34152-1695425815.329395@JT8l.BbmG.WY7I>


[-- Attachment #1.1: Type: text/plain, Size: 1200 bytes --]

On Sat, Sep 23, 2023 at 8:36 AM Oliver Kiddle <opk@zsh.org> wrote:

> Shohei YOSHIDA wrote:
> > gradlew is not usually in the PATH so the command to retrieve tasks
> would fail
> > due to 'command not found'. So it should execute './gradlew' instead of
> 'gradle'
> > if service is gradlew and there is an executable file './gradlew' in
> current
> > directory
>
> Trying to run $service from a completion function is nearly always
> wrong because any path prefix has first been stripped. Rather than
> trying to handle the current directory, it is probably better to just
> use $words[1] instead. Then if someone completes after ../gradlew or
> /somewhere/else/gradlew then it will use the location they specified.
> If there is no gradlew there, they're going to have other problems when
> they try to execute it anyway.
>
> Oliver
>

Thanks for reviewing.
I have updated the patch and attached it.

-- 
Shohei YOSHIDA(syohex@gmail.com)
<http://b.hatena.ne.jp/entry/https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.ja.tLQrNXCHmdo.O/m=m_i,t,it/am=nBHH5b_7g8gZ7tIn1f7977tLmp39J3_3JgBC2Amo_5v9P4jWA_ug_FA/rt=h/d=1/t=zcms/rs=AItRSTNJwrjV1i8LKqdsHFfbx47Tnlb-Bw>

[-- Attachment #1.2: Type: text/html, Size: 2115 bytes --]

[-- Attachment #2: 0001-Fix-gradlew-completion.patch --]
[-- Type: text/x-patch, Size: 1322 bytes --]

From 9ef5a75239316033c3db0d3dee60fea31b91b420 Mon Sep 17 00:00:00 2001
From: Shohei YOSHIDA <syohex@gmail.com>
Date: Fri, 22 Sep 2023 11:36:21 +0900
Subject: [PATCH] Fix gradlew completion

gradlew is not usually in the PATH so the command to retrieve tasks would fail
due to 'command not found'. The location is stripped from '$service' so use
'$words[1]' instead of '$service'
---
 Completion/Unix/Command/_gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_gradle b/Completion/Unix/Command/_gradle
index c1f7c05ee..280aa243f 100644
--- a/Completion/Unix/Command/_gradle
+++ b/Completion/Unix/Command/_gradle
@@ -92,7 +92,7 @@ if [[ $state == task && ! -prefix - ]]; then
                 zle -R "Generating cache from $gradle_buildfile"
 
                 # Run gradle/gradlew and retrieve possible tasks.
-                for outputline in ${(f)"$($service --build-file $gradle_buildfile -q tasks --all)"}; do
+                for outputline in ${(f)"$($words[1] --build-file $gradle_buildfile -q tasks --all)"}; do
 
                     # Tasks and subprojects each start with a lowercase letter, but whereas tasks are in camelCase, each
                     # subproject consists of one or more sections of kebab-case, with each section ending in a ':'.
-- 
2.39.2


      reply	other threads:[~2023-09-23  3:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22  2:50 Shohei YOSHIDA
2023-09-22 23:36 ` Oliver Kiddle
2023-09-23  3:13   ` Shohei Yoshida [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='CAFX6MOMN5oUhAAXJ+WSB6T8sOf5x8=Epejkv3XUxTEfJbUY1nQ@mail.gmail.com' \
    --to=syohex@gmail.com \
    --cc=opk@zsh.org \
    --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).