#625 delete-file cannot delete directory symlink

lisp error
closed-fixed
Sam Steingold
clisp (525)
5
2014-08-20
2011-12-31
Gabor Balazs
No

The delete-file function can remove file and dead symlinks but not (alive) directory symlinks, because it always resolves the provided pathname in the directory symlink case even if it should not (according to the CLISP documentation) :

"(DELETE-FILE pathname) deletes the pathname PATHNAME, not its TRUENAME, ..."

Problem reconstruction:

ls -lR
drwxr-xr-x 2 bege users 4096 Dec 30 19:40 dir
-rw-r--r-- 1 bege users 0 Dec 30 19:26 file
lrwxrwxrwx 1 bege users 4 Dec 30 19:26 link-dead -> dead/
lrwxrwxrwx 1 bege users 3 Dec 30 19:26 link-dir -> dir
lrwxrwxrwx 1 bege users 4 Dec 30 19:26 link-file -> file

./dir:
-rw-r--r-- 1 bege users 0 Dec 30 19:40 dir-file

Then
(delete-file "dir")
*** - DELETE-FILE: "/home/bege/TEST/dir" names a directory, not a file
so the provided pathname is resolved.

However,
(delete-file "link-file")
deletes the link-file link (properly), so in this case the provided pathname is not resolved.

(delete-file "link-dead") works properly too without resolving the dead symlink.

Desired behaviour:
delete-file should not resolve the pathname for a directory symlink and should delete the symlink without error.

Version
clisp --version
GNU CLISP 2.49 (2010-07-07) (built 3529014440) (memory 3529014964)
Software: GNU C 4.5.3
gcc -O2 -march=core2 -fomit-frame-pointer -pipe -Wa,--noexecstack -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O -falign-functions=4 -pthread -DENABLE_UNICODE -DMULTITHREAD -DPOSIX_THREADS -DDYNAMIC_FFI -I. -Wl,-O1 -Wl,--as-needed /usr/lib64/libreadline.so -lncurses -ldl /usr/lib64/libavcall.a /usr/lib64/libcallback.a -L/usr/lib64 -lsigsegv -L/usr/lib64 -lc libgnu_cl.a
SAFETY=0 TYPECODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.8
libreadline 6.2
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP
LISP=CL INTERPRETER MT SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI
GETTEXT UNICODE BASE-CHAR=CHARACTER WORD-SIZE=64 PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib64/clisp-2.49/
User language: ENGLISH
Machine: X86_64 (X86_64) localhost [127.0.0.1]


Discussion

  • Gabor Balazs
    Gabor Balazs
    2011-12-31

    Sorry, there is a mistake in the description, but the error exist. So correctly,

    (delete-file "link-dir")
    *** - DELETE-FILE: "/home/bege/TEST/dir" names a directory, not a file

    / instead of (delete-file "dir") /

     
  • Sam Steingold
    Sam Steingold
    2012-04-27

    thank you for your bug report.
    the bug has been fixed in the source tree (mercurial/hg).
    you can either wait for the next release (recommended)
    or check out the current mercurial tree (see http://clisp.org\)
    and build CLISP from the sources (be advised that between
    releases the source tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold
    Sam Steingold
    2012-04-27

    as explained in http://clisp.org/impnotes/dir-is-not-file.html,
    you should use delete-directory for symlinks to directories.
    however, that also fails.
    I fixed that in the sources, thanks.

     
  • Sam Steingold
    Sam Steingold
    2012-04-27

    • assigned_to: haible --> sds
    • status: open --> closed-fixed