Hello Jim,
This is a Windows platform-specific "side effect". For example, one cannot:
- mkdir a/...
- echo > a/...
But one can:
- cd a/...
When running remove_tree("a/...") on Linux/OSX, this operation fails (prior to the hackathon, no error would be reported, but this is fixed via RT 39949). A goto label is issued when lstat fails (empty array).
When running the same command on Windows, the operation "succeeds". lstat fails back to stat, which does not return an empty array as expected (hence the core RT filing). So the code keeps rolling, and then interprets the path as "destroy a".
I think there are two fundamental problems here:
1. The user code is not portable if the user relies on the lstat failing in order to make decisions. I think it's reasonable to rely on stat.
2. The operation can be very destructive - for example if the user has constructed a variable :
$f = "$a.$b.$c";
And that actually resolves to:
$f = "...";
Then on any platform but Windows the call to remove_tree would not be destructive. But on Windows -- implosion.
On Sun May 03 00:03:09 2015, JKEENAN wrote:
Show quoted text> On Sat May 02 14:31:46 2015, RICHE wrote:
> > Found that the issue is with lstat/stat.
> >
> > Filed defect with perl core.
> >
> >
https://rt.perl.org/Ticket/Display.html?id=124443
> >
> >
> > On Sat May 02 12:03:43 2015, RICHE wrote:
> > > Confirmed this issue as reproducible.
> > >
> > > On Thu Apr 16 09:42:44 2015, lschrieber@sparkim.com wrote:
> > > > Yes, it is Windows-specific, as I indicated in the original bug
> > > > report.
> > > >
> > > > Len Schrieber
> > > > Spark Investment Management LLC
> > > >
> > > > -----Original Message-----
> > > > From: "James E Keenan via RT" <bug-File-Path@rt.cpan.org>
> > > > To: lschrieber@sparkim.com
> > > > Date: 2015-04-15 22:14
> > > > Subject: [rt.cpan.org #90452] File::Path qw(remove_tree)
> > > >
> > > > <URL:
https://rt.cpan.org/Ticket/Display.html?id=90452 >
> > > >
> > > > On Sun Nov 17 11:02:21 2013, lschrieber@sparkim.com wrote:
> > > > > Using perl 5.16.3, windows 7.
> > > > >
> > > > > use File::Path qw(remove_tree);
> > > > >
> > > > > If I say:
> > > > >
> > > > > remove_tree("a/..."); # (any positive number of dots)
> > > > >
> > > > > it removes directory a.
> > > > >
> > > >
> > > > This may be Windows-specific. I could not reproduce the problem
> > > > on
> > > > Ubuntu Linux 14.04-LTS with perl-5.20.1 and File-Path 2.09.
> > > >
> > > > #####
> > > > [tmp] 28 $ mkdir -p a/alpha/beta
> > > > [tmp] 29 $ perl -MFile::Path -e
> > > > 'File::Path::remove_tree("a/...");'
> > > > [tmp] 30 $ ls -l a
> > > > total 4
> > > > drwxrwxr-x 3 jkeenan jkeenan 4096 Apr 15 22:10 alpha
> > > > [tmp] 31 $ ls -l a/alpha/
> > > > total 4
> > > > drwxrwxr-x 2 jkeenan jkeenan 4096 Apr 15 22:10 beta
> > > > #####
> > >
> > >
> >
>
> I've never had occasion to call a function on a path where a path
> separator is followed by 3 dots. So I know what, say, "ls -l xyz/."
> means, and I know what "ls -l xyz/.." means. But I don't know (at
> least in a Unix-based world) what "ls -l xyz/..." in intended to mean?
>
> Can you clarify?
>
> Thank you very much.
> Jim Keenan