Opened 8 years ago

Closed 8 years ago

#1036 closed defect (fixed)

#'rename-file disregards filespec when supplying defaults

Reported by: orivej Owned by:
Priority: normal Milestone:
Component: ANSI CL Compliance Version: trunk
Keywords: Cc: orivej@…


rename-file filespec new-name should supply missing components of new-name from filespec, which it does wrong in the case of (rename-file (make-pathname :name "x.s") "y"). Presently CCL (1.8 and trunk on linuxx86) renames "x.s" to "y.s" because it resolves supplied filespec into its truename via intermediate conversion to a native namestring before supplying defaults.

This is a fix:

--- lib/pathnames.lisp.orig
+++ lib/
@@ -98,7 +98,7 @@
   file, then the associated file is renamed."
   (let* ((original (truename file))
         (original-namestring (native-translated-namestring original))
-        (new-name (merge-pathnames new-name original))
+        (new-name (merge-pathnames new-name (merge-pathnames file)))
         (new-namestring (native-translated-namestring new-name)))
     (unless new-namestring
       (error "~S can't be created." new-name))

Change History (2)

comment:1 Changed 8 years ago by orivej

  • Cc orivej@… added

The inner merge-pathnames is needed not to miss the value of *default-pathname-defaults*.

comment:2 Changed 8 years ago by gb

  • Resolution set to fixed
  • Status changed from new to closed

(In [15543]) Merge RENAME-FILE's first argument with *DEFAULT-PATHNAME-DEFAULTS* before merging the second argument with the result, as suggested by orivej in ticket:1036. I honestly don't know whether this is correct or not.

See 19.2.3; if there's something more conclusive than than that, I haven't found it.

Nominally fixes ticket:1036; may or may not break existing code that depends on old behavior.

Note: See TracTickets for help on using tickets.