* PATCH: _perl_modules assumes it's called by perl
@ 2021-03-29 15:06 Daniel Shahaf
2021-03-29 15:16 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2021-03-29 15:06 UTC (permalink / raw)
To: zsh-workers
A couple of issues in _perl_modules.
1. The condition «[[ ${+perl} -eq 1 ]]» will always be true.
2. If called by some command other than perl, it will invoke that
command as «$foo -e 'print "@INC"'», assuming it to be a perl. For
instance:
.
% compdef _perl_modules git
% git <TAB>
unknown option: -e
⋮
How about the following? —
diff --git a/Completion/Unix/Type/_perl_modules b/Completion/Unix/Type/_perl_modules
index d27a7f7af..02b43366a 100644
--- a/Completion/Unix/Type/_perl_modules
+++ b/Completion/Unix/Type/_perl_modules
@@ -60,10 +60,11 @@ _perl_modules () {
with_pod=_with_pod
fi
- local perl=${words[1]%doc} perl_modules
- if whence $perl >/dev/null; then
+ local perl perl_modules
+ if [[ $service == (perl|perldoc) ]]; then
+ perl=${${(Q)words[1]}%doc}
perl_modules=_${${perl//[^[:alnum:]]/_}#_}_modules$with_pod
- elif (( ${+commands[perl]} )); then
+ elif whence perl > /dev/null; then
perl=perl
perl_modules=_perl_modules$with_pod
else
@@ -81,8 +82,8 @@ _perl_modules () {
else
local inc libdir new_pms
- if [[ ${+perl} -eq 1 ]]; then
- inc=( $( $perl -e 'print "@INC"' ) )
+ if [[ -n $perl ]]; then
+ inc=( $( _call_program perl-inc ${(q)perl}$' -e \'print "@INC"\'' ) )
else
# If perl isn't there, one wonders why the user's trying to
# complete Perl modules. Maybe her $path is wrong?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: _perl_modules assumes it's called by perl
2021-03-29 15:06 PATCH: _perl_modules assumes it's called by perl Daniel Shahaf
@ 2021-03-29 15:16 ` Bart Schaefer
2021-03-29 15:28 ` Daniel Shahaf
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2021-03-29 15:16 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: Zsh hackers list
On Mon, Mar 29, 2021 at 8:07 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
\> + if [[ $service == (perl|perldoc) ]]; then
> + perl=${${(Q)words[1]}%doc}
This still needs to be checked with "whence perl" to make [[ -n $perl
]] have the (intended but messed up) previous semantics.
I otherwise agree with the intent of the patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: _perl_modules assumes it's called by perl
2021-03-29 15:16 ` Bart Schaefer
@ 2021-03-29 15:28 ` Daniel Shahaf
2021-04-08 2:12 ` Daniel Shahaf
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2021-03-29 15:28 UTC (permalink / raw)
To: Zsh hackers list
Bart Schaefer wrote on Mon, 29 Mar 2021 15:16 +00:00:
> On Mon, Mar 29, 2021 at 8:07 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> >
> \> + if [[ $service == (perl|perldoc) ]]; then
> > + perl=${${(Q)words[1]}%doc}
>
> This still needs to be checked with "whence perl" to make [[ -n $perl
> ]] have the (intended but messed up) previous semantics.
>
> I otherwise agree with the intent of the patch.
Thanks for the review. So, just add «whence -- $perl >/dev/null || perl=» after the quoted assignment?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: _perl_modules assumes it's called by perl
2021-03-29 15:28 ` Daniel Shahaf
@ 2021-04-08 2:12 ` Daniel Shahaf
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2021-04-08 2:12 UTC (permalink / raw)
To: Zsh hackers list
Daniel Shahaf wrote on Mon, Mar 29, 2021 at 15:28:52 +0000:
> Bart Schaefer wrote on Mon, 29 Mar 2021 15:16 +00:00:
> > On Mon, Mar 29, 2021 at 8:07 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > >
> > \> + if [[ $service == (perl|perldoc) ]]; then
> > > + perl=${${(Q)words[1]}%doc}
> >
> > This still needs to be checked with "whence perl" to make [[ -n $perl
> > ]] have the (intended but messed up) previous semantics.
> >
> > I otherwise agree with the intent of the patch.
>
> Thanks for the review. So, just add «whence -- $perl >/dev/null || perl=» after the quoted assignment?
Interdiff:
diff --git a/Completion/Unix/Type/_perl_modules b/Completion/Unix/Type/_perl_modules
index 02b43366a..3e11de9ea 100644
--- a/Completion/Unix/Type/_perl_modules
+++ b/Completion/Unix/Type/_perl_modules
@@ -61,8 +61,8 @@ _perl_modules () {
fi
local perl perl_modules
- if [[ $service == (perl|perldoc) ]]; then
- perl=${${(Q)words[1]}%doc}
+ if [[ $service == (perl|perldoc) ]] && whence -- ${${(Q)words[1]}%doc} >/dev/null; then
+ perl=$_
perl_modules=_${${perl//[^[:alnum:]]/_}#_}_modules$with_pod
elif whence perl > /dev/null; then
perl=perl
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-08 2:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 15:06 PATCH: _perl_modules assumes it's called by perl Daniel Shahaf
2021-03-29 15:16 ` Bart Schaefer
2021-03-29 15:28 ` Daniel Shahaf
2021-04-08 2:12 ` Daniel Shahaf
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).