diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2017-09-25 23:46:54 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2017-09-25 23:46:54 -0300 |
commit | 6d88f1055806932d9291f96847d2b691cccda2cd (patch) | |
tree | 0ff79eedaa8a239331256048981deedbd0721965 /helpers/perl | |
parent | 059a87a5936cfebfd2d71ab8057002cafb2ea051 (diff) | |
download | bash-completion-6d88f1055806932d9291f96847d2b691cccda2cd.tar.gz |
New upstream version 2.7upstream/2.7
Diffstat (limited to 'helpers/perl')
-rw-r--r-- | helpers/perl | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/helpers/perl b/helpers/perl index f847dc74..2a01a096 100644 --- a/helpers/perl +++ b/helpers/perl @@ -2,12 +2,13 @@ use strict; use Config; +use Cwd; use File::Spec::Functions; my %seen; sub print_modules_real { - my ($base, $dir, $word) = @_; + my ($base, $dir, $word, $include_pod) = @_; # return immediately if potential completion doesn't match current word # a double comparison is used to avoid dealing with string lengths @@ -23,8 +24,9 @@ sub print_modules_real { chdir($dir) or return; # print each file - foreach my $file (glob('*.pm')) { - $file =~ s/\.pm$//; + foreach my $file (sort(glob('*.pm'),glob('*.pod'))) { + next if ($file =~ /\.pod$/ and not $include_pod); + $file =~ s/\.(?:pm|pod)$//; my $module = $base . $file; next if $module !~ /^\Q$word/; next if $seen{$module}++; @@ -36,19 +38,21 @@ sub print_modules_real { my $subdir = $dir . '/' . $directory; if ($directory =~ /^(?:[.\d]+|$Config{archname}|auto)$/) { # exclude subdirectory name from base - print_modules_real(undef, $subdir, $word); + print_modules_real(undef, $subdir, $word, $include_pod); } else { # add subdirectory name to base - print_modules_real($base . $directory . '::', $subdir, $word); + print_modules_real($base . $directory . '::', $subdir, $word, $include_pod); } } } sub print_modules { - my ($word) = @_; + my ($word, $include_pod) = @_; + my $origdir = getcwd; foreach my $directory (@INC) { - print_modules_real(undef, $directory, $word); + print_modules_real(undef, $directory, $word, $include_pod); + chdir $origdir; } } @@ -86,4 +90,7 @@ if ($type eq 'functions') { print_functions($word); } elsif ($type eq 'modules') { print_modules($word); +} elsif ($type eq 'perldocs') { + print_modules($word, 1); } + |