comments rule
This commit is contained in:
parent
52d578a956
commit
d1b62c2ece
1 changed files with 13 additions and 0 deletions
13
stow.in
13
stow.in
|
@ -40,6 +40,8 @@ $Stow = undef;
|
||||||
$Target = undef;
|
$Target = undef;
|
||||||
$Restow = 0;
|
$Restow = 0;
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME: use Getopt::Long
|
||||||
while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
|
while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
|
||||||
$opt = $';
|
$opt = $';
|
||||||
shift;
|
shift;
|
||||||
|
@ -114,10 +116,13 @@ while (@ARGV && ($_ = $ARGV[0]) && /^-/) {
|
||||||
|
|
||||||
&usage("No packages named") unless @ARGV;
|
&usage("No packages named") unless @ARGV;
|
||||||
|
|
||||||
|
# Changing dirs helps a lot when soft links are used
|
||||||
$current_dir = &getcwd;
|
$current_dir = &getcwd;
|
||||||
if ($Stow) {
|
if ($Stow) {
|
||||||
chdir($Stow) || die "Cannot chdir to target tree $Stow ($!)\n";
|
chdir($Stow) || die "Cannot chdir to target tree $Stow ($!)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This prevents problems if $Target was supplied as a relative path
|
||||||
$Stow = &getcwd;
|
$Stow = &getcwd;
|
||||||
|
|
||||||
chdir($current_dir) || die "Your directory does not seem to exist anymore ($!)\n";
|
chdir($current_dir) || die "Your directory does not seem to exist anymore ($!)\n";
|
||||||
|
@ -159,6 +164,9 @@ sub CommonParent {
|
||||||
$result;
|
$result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Find the relative patch between
|
||||||
|
# two paths given as arguments.
|
||||||
|
|
||||||
sub RelativePath {
|
sub RelativePath {
|
||||||
local($a, $b) = @_;
|
local($a, $b) = @_;
|
||||||
local($c) = &CommonParent($a, $b);
|
local($c) = &CommonParent($a, $b);
|
||||||
|
@ -177,6 +185,9 @@ sub RelativePath {
|
||||||
&JoinPaths(@b);
|
&JoinPaths(@b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Basically concatenates the paths given
|
||||||
|
# as arguments
|
||||||
|
|
||||||
sub JoinPaths {
|
sub JoinPaths {
|
||||||
local(@paths, @parts);
|
local(@paths, @parts);
|
||||||
local ($x, $y);
|
local ($x, $y);
|
||||||
|
@ -265,6 +276,8 @@ sub Unstow {
|
||||||
$pure = 0;
|
$pure = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# This directory was an initially empty directory therefore
|
||||||
|
# We do not remove it.
|
||||||
$pure = 0 if $empty;
|
$pure = 0 if $empty;
|
||||||
if ((!$pure || !$targetdir) && @puresubdirs) {
|
if ((!$pure || !$targetdir) && @puresubdirs) {
|
||||||
&CoalesceTrees($targetdir, $stow, @puresubdirs);
|
&CoalesceTrees($targetdir, $stow, @puresubdirs);
|
||||||
|
|
Loading…
Reference in a new issue