aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-04 12:08:14 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-04 12:08:14 +0300
commit3284f879c364a2a7b6d9c1227b21c6ed29246d28 (patch)
tree78f819aee72c5f06e8cb24cc58dd80c4b7852201 /lib
parent0b57289838dd536d6f98696e16a06c3663535b8e (diff)
downloadmangemanche-3284f879c364a2a7b6d9c1227b21c6ed29246d28.tar.gz
mangemanche-3284f879c364a2a7b6d9c1227b21c6ed29246d28.tar.bz2
Don't list duplicate commands
* lib/App/Mangemanche.pm (list_commands): Load script by its relative name so its duplicates can be found in %INC.
Diffstat (limited to 'lib')
-rw-r--r--lib/App/Mangemanche.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/App/Mangemanche.pm b/lib/App/Mangemanche.pm
index d0992f2..228f8fc 100644
--- a/lib/App/Mangemanche.pm
+++ b/lib/App/Mangemanche.pm
@@ -126,17 +126,18 @@ sub list_commands {
126 my @classpath = (split(/::/, $class), 'Command'); 126 my @classpath = (split(/::/, $class), 'Command');
127 127
128 print "\nAvailable commands are:\n"; 128 print "\nAvailable commands are:\n";
129 foreach my $mod (sort 129 foreach my $mod (sort
130 map { 130 map {
131 my $name = basename($_); 131 my $name = basename($_);
132 if (exists($INC{File::Spec->catfile(@classpath,$name)})) { 132 my $filename = File::Spec->catfile(@classpath,$name);
133 if (exists($INC{$filename})) {
133 () 134 ()
134 } else { 135 } else {
135 eval { 136 eval {
136 require $_; 137 require $filename;
137 }; 138 };
138 $name =~ s/\.pm$//; 139 $name =~ s/\.pm$//;
139 $@ ? () : [$name, $_]; 140 $@ ? () : [$name, $_];
140 } 141 }
141 } 142 }
142 map { 143 map {

Return to:

Send suggestions and report system problems to the System administrator.