3
use autouse Data::Dumper, qw{Dumper};
5
# Script to find the unused shell functions in slapd.scripts-common
9
# Get all shell code from maintainer scripts
11
foreach my $file ((<slapd.*rm>, <slapd.*inst>, <slapd.config>,
12
<slapd.scripts-common>)) {
13
open SCRIPT, "<$file" or
14
die "Can't open $file: $!";
19
# Find all function declarations
21
our @functions = map { /^(\w+)\s*\(\).*$/; } @code;
23
# Find unused functions
25
foreach $function (@functions) {
26
@occurences = grep /$function/, @code;
27
@invocations = grep { !/^$function\s*\(\)/ and !/#.*$function/ }
29
print "$function\n" if @invocations == 0;