Skip Menu |
 

This queue is for tickets about the PathTools CPAN distribution.

Report information
The Basics
Id: 80077
Status: new
Priority: 0/
Queue: PathTools

People
Owner: Nobody in particular
Requestors: eric.roode+cpan [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 3.33
  • 3.39_01
Fixed in: (no value)



Subject: chdir() fails for UNC paths under cygwin
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1195
Download (untitled) / with headers
text/plain 1.1k
Microsoft systems specify network locations with UNC, with paths of the form: \\ServerName\path\path\path\ Cygwin represents such paths with forward-slashes. When running under cygwin, Cwd::cwd() will return something like "//server-foo/bar/dir". File::Spec->canonpath() accepts this format (and returns it unchanged). File::Spec->rel2abs('.') will return a string of this format. *** But Cwd::chdir('//server-foo/bar/dir') does not work! The problem seems to be the second line of the function chdir() in Cwd.pm: $newdir =~ s|///*|/|g unless $^O eq 'MSWin32'; That removes all double forward-slashies, including the necessary pair at the start of the string. Then chdir() calls CORE::chdir on '/server-foo/bar/dir', which fails with "No such file or directory". I suggest replacing that line with the following code: if ($^O eq 'cygwin') { # remove multiple slashes except at beginning $newdir =~ s|([^/])/{2,}|$1/|g; } elsif ($^O ne 'MSWin32') { $newdir =~ s|/{2,}|/|g; } That first substitution would probably be better written as: $newdir =~ s|(?<!\A)/{2,}|/|g; but you may not want to use that since it would break on really old perls.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.