From: Wolfgang Laun Date: Wed, 12 Dec 2001 10:52:21 +0000 (+0100) Subject: Re: [PATCH] ID 20011206.007 File::Find:name set to empty string for "/" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5cf0a2f2007e5a1f536bf01bb814c9223a9c47b9;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] ID 20011206.007 File::Find:name set to empty string for "/" Message-ID: <200112121052210220.001ACE6B@smtp.chello.at> p4raw-id: //depot/perl@13654 --- diff --git a/lib/File/Find.pm b/lib/File/Find.pm index 3fbeebc..a0cfcb9 100644 --- a/lib/File/Find.pm +++ b/lib/File/Find.pm @@ -150,7 +150,22 @@ C<$File::Find::dir> contains the current directory name, and C<$_> the current filename within that directory. C<$File::Find::name> contains the complete pathname to the file. You are chdir()'d to C<$File::Find::dir> when the function is called, unless C -was specified. When C or C are in effect, there is +was specified. Note that when changing to directories is in effect +the root directory (F) is a somewhat special case inasmuch as the +concatenation of C<$File::Find::dir>, C<'/'> and C<$_> is not literally +equal to C<$File::Find::name>. The table below summarizes all variants: + + $File::Find::name $File::Find::dir $_ + default / / . + no_chdir=>0 /etc / etc + /etc/x /etc x + + no_chdir=>1 / / / + /etc / /etc + /etc/x /etc /etc/x + + +When or are in effect, there is also a C<$File::Find::fullname>. The function may set C<$File::Find::prune> to prune the tree unless C was specified. Unless C or C is specified, for @@ -863,12 +878,12 @@ sub _find_dir($$$) { } else { if ( substr($name,-2) eq '/.' ) { - $name =~ s|/\.$||; + substr($name, length($name) == 2 ? -1 : -2) = ''; } $dir = $p_dir; $_ = ($no_chdir ? $dir_name : $dir_rel ); if ( substr($_,-2) eq '/.' ) { - s|/\.$||; + substr($_, length($_) == 2 ? -1 : -2) = ''; } } # guarantee lstat at return to directory