cleanlinks (Imake).

Ag. Hatzimanikas a.hatzim at gmail.com
Tue Dec 19 16:56:30 PST 2006


Hi All,

cleanlinks is a small script which checks for dangling symbolic 
links and empty directories (and removes them if finds any),that 
is get installed by Imake.

However the syntax is wrong and will remove symbolic links that point to 
directories,which is not the expected behavior.
See,
=====================================================================
find . -type l -print |
(
	read i
	while [ X"$i" != X ]; do
		if [ ! -f "$i" ]; then
		~~~~~~~~~~~~~~~~~~~~~~
			echo $i is a dangling symlink, removing
			rm -f "$i"
		fi
		read i
	done
)
=====================================================================

This can be changed either with

if ! ([ -f "$i" ] || [ -d "$i" ]); then

or even with 
if [ ! -e "$i" ];then

And there is also a wrong syntax with a recent find.

find . -type d -depth -empty -print -exec rmdir {} \;

which the "-type d" should go after the -depth option.

Anyway the script
a.it's not safe (don't try to do cleanlinks --help,if you are in a dir
with some symbolic links to directories)
b.it doesn't fit in /usr/bin (it can be replaced easily with a personal script),
and it doesn't fit with the purpose of the Imake utility.
As the man page says it was useful for cleaning up a shadow link tree created with
lndir.

By the way,as it well known,Imake is deprecated and will be removed in the feature,but 
is really needed to build modular xorg (I think not), or is still anything depends
on it in BLFS (apart from some random old applications which are not present in the
Book)?



More information about the blfs-dev mailing list