if "davesdots" is in the home dir, use rel symlink

This commit is contained in:
David Majnemer 2010-07-09 00:19:48 -07:00
parent bddbd53417
commit ed573dafbd

View file

@ -86,6 +86,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.
@ -108,6 +115,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";
}