add_underlay: avoid adding the same underlay twice
authorJoey Hess <joey@kodama.kitenet.net>
Fri, 17 Oct 2008 23:53:04 +0000 (19:53 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Fri, 17 Oct 2008 23:53:04 +0000 (19:53 -0400)
IkiWiki.pm

index 633c5138180a9f87f4a974bef3322492c1d08ada..edee8aacb707e93081b1dfdec7a21a1f04e361bb 100644 (file)
@@ -681,11 +681,12 @@ sub srcfile ($;$) { #{{{
 sub add_underlay ($) { #{{{
        my $dir=shift;
 
-       if ($dir=~/^\//) {
-               unshift @{$config{underlaydirs}}, $dir;
+       if ($dir !~ /^\//) {
+               $dir="$config{underlaydir}/../$dir";
        }
-       else {
-               unshift @{$config{underlaydirs}}, "$config{underlaydir}/../$dir";
+
+       if (! grep { $_ eq $dir } @{$config{underlaydirs}}) {
+               unshift @{$config{underlaydirs}}, $dir;
        }
 
        return 1;