JoinPaths is weird after all
This commit is contained in:
parent
921041f2a8
commit
d2afbae421
1 changed files with 16 additions and 9 deletions
25
Stow.pm
25
Stow.pm
|
@ -116,16 +116,23 @@ sub RelativePath {
|
||||||
&JoinPaths(@b);
|
&JoinPaths(@b);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Concatenates the paths given as arguments, removing double slashes.
|
# Concatenates the paths given as arguments, removing double and
|
||||||
|
# trailing slashes. Is subtlely different from File::Spec::join
|
||||||
|
# in other aspects, e.g. args ('', '/foo') yields 'foo' not '/foo'.
|
||||||
sub JoinPaths {
|
sub JoinPaths {
|
||||||
# The code that was previously here from 1.3.3 was strangely complex
|
my(@paths, @parts);
|
||||||
# for no obvious reason. I (Adam) wrote a test suite and found this
|
my ($x, $y);
|
||||||
# drop-in replacement to behave identically.
|
my($result) = '';
|
||||||
# my $result = join '/', @_;
|
|
||||||
# $result =~ s!//!/!g;
|
$result = '/' if ($_[0] =~ /^\//);
|
||||||
# return $result;
|
foreach $x (@_) {
|
||||||
# So does this, but is also portable.
|
@parts = split(/\/+/, $x);
|
||||||
return File::Spec->join(@_);
|
foreach $y (@parts) {
|
||||||
|
push(@paths, $y) if ($y ne "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result .= join('/', @paths);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
# This removes stow-controlled symlinks from $targetdir for the
|
# This removes stow-controlled symlinks from $targetdir for the
|
||||||
|
|
Loading…
Reference in a new issue