Check elements of PATH for accessibilty, and for possibly conflicting program names.

This script checks all the directories in $PATH for accessibility, then it checks specific named arguments for possible conflicts between different directories in the $PATH. If no arguments are named, all programs in the $PATH are examined for conflicts.

Directories which are equivalent (symlinks) are removed from the list before the file analysis is made, to cut down on spurious conflicts. Apparent conflicts which are symlinks to the same file are also not reported. Most systems seem to have many of these.

This cannot get all possible conflicts for all shells and all situations. Specifically, it does not address shell aliases, built-ins or global shell functions, all of which are shell-dependant. Nor can it address temporary conflicts caused by a startup script which augments $PATH and then spawns child processes which perform a $PATH search.

Warning: A path element containing "~" is not valid in sh/ksh, but is valid in bash and some csh/tcsh. Normally the "~" is expanded when the path is set. We test (with "-d") for the presence of a directory and this fails because "~" is not expanded inside the test operation. In bash, the test fails, the "~" still works as a path element. It is most reliable to use $HOME explicitly, not "~", in $PATH


-v verbosity
0 - terse output if conflicts are found.
1 - medium output if conflicts are found (default)
2 - long output. List all potential conflicts, even if multiple pathnames resolve to the same file. Follow symlinks to their final destinations. Run 'file' on each conflicting pathname.
3 - Additional debugging information
directory check only - don't analyse any filenames
path check only, no directory report.

Exit status:
0 = all directories in PATH are accessible.
>0 = a count of the inaccessible directories. (the exit status does not reflect whether pathname conflicts were discovered)

2004/11/03 Richard Brittain, Dartmouth College Computing Services.
Last update: 2009/02/07

Richard's Software Page
Richard Brittain