Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Pathfinder - find duplicate (shadowed) programs in your PATH

by toolic (Bishop)
on Jul 20, 2009 at 21:22 UTC ( #781768=note: print w/replies, xml ) Need Help??


in reply to Pathfinder - find duplicate (shadowed) programs in your PATH

I like how the code identifies duplicate PATH directories by using the inode. The system administrators who set up the environment I use at $work have added in a few duplicate directories. In my case, they are not links; so the warning message is a little misleading, but the important thing is that I get some kind of warning.

Currently, the code only filters out the specially-name directories (. and ..). I adapted the code to filter out all directories which are sub-directories of each PATH directory. Also, I filter out all files which do not have execute permissions.

To add these filters, change:

sort grep !/^\.\.?$/,

to:

sort grep {-x "$dir/$_"} grep {! -d "$dir/$_"}

Replies are listed 'Best First'.
Re^2: Pathfinder - find duplicate (shadowed) programs in your PATH
by parv (Priest) on Jul 21, 2009 at 04:17 UTC

    Does grep {  ! -d "$dir/$_" && -x _ } not work?

    Few hours later, changed second "$dir/$_" with _.

    Thanks to toolic for catching the missing quote that I had lost during editing.

      Does grep { ! -d "$dir/$_ && -x _ } not work?
      Yes, I believe your Other Way To Do It is functionally equivalent to my code (assuming you close the quotes, of course). Your version has fewer keystrokes, and it may even run faster since it has one fewer grep, if one were so inclined to benchmark it. It produced the same results as my code.

        Ah, thanks for catching the missing quote. During editing, I lost it.

        The point was neither reduction in typing nor increase in raw speed, though. To me personally, the extra grep was gratuitous; more importantly, cached results of one file test were not being used for another file test.

        (Perhaps I should have put something along the lines of "unless your effort was one off or were just testing" somewhere in my previous reply.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://781768]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-09-19 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (170 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!