30
10 | 2013
Beware of symlinks when testing a file existence
Classified in : Debian, Command line, To remember
A strange problem
Yesterday, I was reported a funny problem with the dokuwiki Debian package's postinst script, which contains a piece of shell script similar to that:
# Check the destination does not already exist
if [ ! -e /the/destination ]
then
ln -s /some/file /the/destination
fi
It was failing with that message: ln: failed to
create symbolic link '/the/destination': File exists. Even
though I had just tested it did not exist!