changeset 3263:82b564084ce6

(file-chase-links): Handle leading .. in symlink target.
author Richard M. Stallman <rms@gnu.org>
date Sat, 29 May 1993 20:13:58 +0000
parents 4ece9a6d1f37
children eff921d7bde6
files lisp/files.el
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Sat May 29 20:07:50 1993 +0000
+++ b/lisp/files.el	Sat May 29 20:13:58 1993 +0000
@@ -351,6 +351,20 @@
     (while (setq tem (file-symlink-p newname))
       (if (= count 0)
 	  (error "Apparent cycle of symbolic links for %s" filename))
+      ;; Handle `..' by hand, since it needs to work in the
+      ;; target of any directory symlink.
+      ;; This code is not quite complete; it does not handle
+      ;; embedded .. in some cases such as ./../foo and foo/bar/../../../lose.
+      (while (string-match "\\.\\./" tem)
+	(setq tem (substring tem 3))
+	(setq newname (file-name-as-directory
+		       ;; Do the .. by hand.
+		       (directory-file-name
+			(file-name-directory
+			 ;; Chase links in the default dir of the symlink.
+			 (file-chase-links
+			  (directory-file-name
+			   (file-name-directory newname))))))))
       (setq newname (expand-file-name tem (file-name-directory newname)))
       (setq count (1- count)))
     newname))