This is a tool to help with colon-separated paths found in Unix, such as PATH, MANPATH, PERL5LIB, CLASSPATH and many others. It is common to add to these in login scripts by prepending or appending new directories. However this can lead to the same directory being duplicated in the path, and to unwieldy command lines. With pathmerge, you can say instead things like:
export PATH=`pathmerge\
$HOME/bin\
$HOME/wine/inst/bin\
$HOME/lib/ant/bin\
/bin\
/usr/bin\
/usr/local/maple/bin\
$PATH\
/opt/kde/bin\
/usr/X11R6/bin\
`
and these directories will be added to PATH at the positions
shown, unless they were already present, in which case the first
of the two occurrences is included.
If the -d flag is given then pathmerge warns about entries which aren't directories and skips them; this is a way to clean cruft out of your PATH and other environment variables.
Pathmerge is a small utility, but it tries to reproduce the correct semantics of paths, including treatment of empty path components. It includes a manual page and test suite.
The current version is 0.2 which adds the -d flag.
All the files are in the public domain. This means there are no copyright restrictions, you may do what you wish with them. Of course, giving credit would be appreciated (but not required).
They are offered as-is with no warranty whatsoever.
Please contact me, Ed Avis <ed@membled.com> with any suggestions or bug reports.
This program has a web page at http://membled.com/work/apps/pathmerge/.