From 0912572ba6e2b33d2a7d401dee9b548159377163 Mon Sep 17 00:00:00 2001 From: bbrtj Date: Fri, 17 May 2024 19:57:49 +0200 Subject: [PATCH] Avoid using $_ when loading the commands from namespaces resolves #2175 --- lib/Mojolicious/Commands.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Mojolicious/Commands.pm b/lib/Mojolicious/Commands.pm index 22935931be..a95d542fdb 100644 --- a/lib/Mojolicious/Commands.pm +++ b/lib/Mojolicious/Commands.pm @@ -65,8 +65,10 @@ sub run { # Find all available commands my %all; for my $ns (@{$self->namespaces}) { - $all{substr $_, length "${ns}::"} //= $_->new->description - for grep { _command($_) } find_modules($ns), find_packages($ns); + for my $pkg (find_modules($ns), find_packages($ns)) { + next unless _command($pkg); + $all{substr $pkg, length "${ns}::"} //= $pkg->new->description + } } my @rows; @@ -323,3 +325,4 @@ C<--home> and C<-m>/C<--mode>, which are shared by all commands, will be parsed L, L, L. =cut +