On Wed, Aug 06, 2003 at 07:56:00PM +0200, Florian Ernst wrote: > It appears the "cleanlinks"-script only checks for the symlinks-target > "file" but not for "directory", so the following patch could fix it: > > --- /usr/bin/X11/cleanlinks.old 2003-02-26 01:52:11.000000000 +0100 > +++ /usr/bin/X11/cleanlinks 2003-08-06 18:40:30.000000000 +0200 > @@ -13,7 +13,7 @@ > ( > read i > while [ X"$i" != X ]; do > - if [ ! -f "$i" ]; then > + if [ ! \( -f "$i" -o -d "$i" \) ]; then > echo $i is a dangling symlink, removing > rm -f "$i" > fi
A slightly more portable version would be better, I think (using parenthesis-grouping in [] is a bit dodgy): - if [ ! -f "$i" ]; then + if ! ([ -f "$i" ] || [ -d "$i" ]); then This still seems incomplete, though. What if it's a symlink to a device node? We could simply do this instead to test whether the symlink is truly dangling: - if [ ! -f "$i" ]; then + if [ ! -e "$i" ]; then XFree86 might not be able to do this if they want to run on Solaris, whose /bin/sh doesn't understand test -e, but it's fine on any POSIX system. Somebody might want to make sure that other shells return the same result from test -e on a dangling symlink, but my reading of http://www.opengroup.org/onlinepubs/007904975/utilities/test.html is that any shell that doesn't is buggy. Cheers, -- Colin Watson [EMAIL PROTECTED]