Ooh, and make links to . and .. work properly as well.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 21 Nov 2004 14:25:38 +0000 (14:25 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 21 Nov 2004 14:25:38 +0000 (14:25 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/utils@4870 cda61777-01e9-0310-a592-d414129be87e

lns/lns

diff --git a/lns/lns b/lns/lns
index f7a344c..9ab3e63 100755 (executable)
--- a/lns/lns
+++ b/lns/lns
@@ -219,6 +219,13 @@ sub relname {
 
   while (1) {
 
+    # If $target is _precisely_ $source, we are done.
+    if ($target eq $source) {
+      return "." if $prefix eq "";
+      $prefix =~ s/\/$//;
+      return $prefix;
+    }
+
     # If $target is a prefix of $source, we are done. (No matter what
     # symlinks may exist on the shared common pathname, if we are
     # linking `a/b/c/foo' to `foo' then a simple relative link will