Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix gradlew completion
- X-seq: zsh-workers 52179
- From: Shohei Yoshida <syohex@xxxxxxxxx>
- To: Oliver Kiddle <opk@xxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] Fix gradlew completion
- Date: Sat, 23 Sep 2023 12:13:36 +0900
- Archived-at: <https://zsh.org/workers/52179>
- In-reply-to: <34152-1695425815.329395@JT8l.BbmG.WY7I>
- List-id: <zsh-workers.zsh.org>
- References: <20230922025003.33716-1-syohex@gmail.com> <34152-1695425815.329395@JT8l.BbmG.WY7I>
On Sat, Sep 23, 2023 at 8:36 AM Oliver Kiddle <
opk@xxxxxxx> 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.
--
From 9ef5a75239316033c3db0d3dee60fea31b91b420 Mon Sep 17 00:00:00 2001
From: Shohei YOSHIDA <syohex@xxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author