Category: | Utility Scripts |
Author/Contact Info | Randal L. Schwartz - merlyn |
Description: | Run this program (no arguments) and see which items in your PATH environment setting are shadowing later programs of the same name. This is an indication that you might get failures running the scripts of others, or perhaps if you ever rearrange your PATH. |
#!/usr/bin/perl -w use strict; my @path = split /:/, $ENV{PATH}; my %path_inodes; my @clean_path; for (@path) { next unless m#^/#; my ($dev,$ino) = stat; next unless defined $dev; my $key = "$dev $ino"; if (exists $path_inodes{$key}) { print "warning: $_ is linked to $path_inodes{$key}\n"; next; } $path_inodes{$key} = $_; push @clean_path, $_; } my %progs; ## print "clean path is @clean_path\n"; for my $dir (@clean_path) { use DirHandle; my @files = sort grep !/^\.\.?$/, DirHandle->new($dir)->read; ## print "$dir: @files\n"; for my $file (@files) { if (exists $progs{$file}) { print "$file in $dir is shadowed by $progs{$file}\n"; next; } $progs{$file} = $dir; } } |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pathfinder - find duplicate (shadowed) programs in your PATH
by toolic (Bishop) on Jul 20, 2009 at 21:22 UTC | |
by parv (Parson) on Jul 21, 2009 at 04:17 UTC | |
by toolic (Bishop) on Jul 22, 2009 at 01:37 UTC | |
by parv (Parson) on Jul 22, 2009 at 12:02 UTC |
Back to
Code Catacombs