Simple tool to clean up PATH like strings by removing redundant and incorrect entries but keeping the relative order of the paths that remain.
For example:
$ export FAKEPATH=/usr/bin:/usr/local/bin:/usr/bin:/usr/sbin:.
$ export FAKEPATH=$(cleanpath $FAKEPATH)
$ echo $FAKEPATH
/usr/bin:/usr/local/bin:/usr/sbin
Notice:
- Redundant paths removed, but relative order of first occurence is maintained.
- Relative (unsafe) paths removed.