`lns . subdir' was trying to create a link called `subdir/.',
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 13 Sep 2007 13:00:37 +0000 (13:00 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 13 Sep 2007 13:00:37 +0000 (13:00 +0000)
invariably unsuccessfully. The more useful behaviour, and also more
intuitive IMO, is to have it create `subdir/dirname' where `dirname'
is the name of the last path component of your cwd.

git-svn-id: svn://svn.tartarus.org/sgt/utils@7720 cda61777-01e9-0310-a592-d414129be87e

lns/lns

diff --git a/lns/lns b/lns/lns
index d44dc8c..db35f9a 100755 (executable)
--- a/lns/lns
+++ b/lns/lns
@@ -107,6 +107,11 @@ $target =~ s/// if $target =~ /\/$/;    # strip trailing slash if present
 
 if ($multiple) {
   foreach $source (@ARGV) {
+    # We must path-normalise $source _before_ looking for the final
+    # filename component, to deal with the case of `lns . subdir'
+    # in which we want the link to be called subdir/<dirname> rather
+    # than subdir/. .
+    $source = &normalise($source);
     $source =~ /^(.*\/)?([^\/]*)$/;     # find final file name component
     &makelink($source, "$target/$2");   # actually make a link
   }