Merge branch 'master' of ssh://majnematic.com/davesdots

This commit is contained in:
David Majnemer 2010-07-09 11:10:06 -07:00
commit 26b7289812

View file

@ -84,6 +84,13 @@ my %links = (
gdbinit => '.gdbinit',
);
my $contained = (substr $scriptdir, 0, length($home)) eq $home;
my $prefix = undef;
if ($contained) {
$prefix = substr $scriptdir, length($home);
($prefix) = $prefix =~ m{^\/? (.+) [^/]+ $}x;
}
my $i = 0; # Keep track of how many links we added
for my $file (keys %links) {
# See if this file resides in a directory, and create it if needed.
@ -106,6 +113,15 @@ for my $file (keys %links) {
unlink($dest) || warn "Couldn't unlink '$dest': $!\n";
}
if ($contained) {
chdir $home;
$dest = "$links{$file}";
$src = "$prefix$file";
if ($path) {
$src = "../$src";
}
}
symlink($src => $dest) ? $i++ : warn "Couldn't link '$src' to '$dest': $!\n";
}