[perl #8599] s/catenate/concatenate/
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / Unix.pm
index 4d917a0..904b657 100644 (file)
@@ -1,7 +1,7 @@
 package File::Spec::Unix;
 
 use strict;
-our($VERSION);
+use vars qw($VERSION);
 
 $VERSION = '1.4';
 
@@ -127,8 +127,9 @@ sub rootdir {
 
 =item tmpdir
 
-Returns a string representation of the first writable directory
-from the following list or "" if none are writable:
+Returns a string representation of the first writable directory from
+the following list or the current directory if none from the list are
+writable:
 
     $ENV{TMPDIR}
     /tmp
@@ -139,14 +140,15 @@ is tainted, it is not used.
 =cut
 
 my $tmpdir;
-sub tmpdir {
+sub _tmpdir {
     return $tmpdir if defined $tmpdir;
-    my @dirlist = ($ENV{TMPDIR}, "/tmp");
+    my $self = shift;
+    my @dirlist = @_;
     {
        no strict 'refs';
        if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0
             require Scalar::Util;
-           shift @dirlist if Scalar::Util::tainted($ENV{TMPDIR});
+           @dirlist = grep { ! Scalar::Util::tainted($_) } @dirlist;
        }
     }
     foreach (@dirlist) {
@@ -154,10 +156,17 @@ sub tmpdir {
        $tmpdir = $_;
        last;
     }
-    $tmpdir = '' unless defined $tmpdir;
+    $tmpdir = $self->curdir unless defined $tmpdir;
+    $tmpdir = defined $tmpdir && $self->canonpath($tmpdir);
     return $tmpdir;
 }
 
+sub tmpdir {
+    return $tmpdir if defined $tmpdir;
+    my $self = shift;
+    $tmpdir = $self->_tmpdir( $ENV{TMPDIR}, "/tmp" );
+}
+
 =item updir
 
 Returns a string representation of the parent directory.  ".." on UNIX.
@@ -317,7 +326,7 @@ sub splitdir {
 =item catpath()
 
 Takes volume, directory and file portions and returns an entire path. Under
-Unix, $volume is ignored, and directory and file are catenated.  A '/' is
+Unix, $volume is ignored, and directory and file are concatenated.  A '/' is
 inserted if needed (though if the directory portion doesn't start with
 '/' it is not added).  On other OSs, $volume is significant.