From: simon Date: Thu, 13 Sep 2007 13:00:37 +0000 (+0000) Subject: `lns . subdir' was trying to create a link called `subdir/.', X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/utils/commitdiff_plain/9d63af994dcdeabc463fcf3b841c931ce4cb80b6?hp=6868f2f76462d8960ae3328c318b5fb827ea282b `lns . subdir' was trying to create a link called `subdir/.', 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 --- diff --git a/lns/lns b/lns/lns index d44dc8c..db35f9a 100755 --- 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/ rather + # than subdir/. . + $source = &normalise($source); $source =~ /^(.*\/)?([^\/]*)$/; # find final file name component &makelink($source, "$target/$2"); # actually make a link }