File::Spec::Unix->tmpdir: Always return an absolute path
authorBrian Fraser <fraserbn@gmail.com>
Fri, 17 Jan 2014 17:53:58 +0000 (14:53 -0300)
committerBrian Fraser <fraserbn@gmail.com>
Fri, 24 Jan 2014 17:53:42 +0000 (14:53 -0300)
commite0580a69498c2947ff447422771cbabc77945e2d
tree55f465598a3629683c208b96d4f839185d0f48a7
parent6fbeaf2cefaf9e56416f1453f4b8bac8f1f3f46c
File::Spec::Unix->tmpdir: Always return an absolute path

This is generally a non-issue, however, if /tmp doesn't exist
and $ENV{TMPDIR} isn't set, ->tmpdir() used to return ".", which
broke the following pattern:

    use File::Temp qw(tempdir);
    use File::Spec;
    my $tmpdir = tempdir(CLEANUP => 1);
    chdir $tmpdir;
    my $file = File::Spec->catfile($tmpdir, "foo");
    open my $fh, ">", $file or die $!;

Because $tmpdir would be something like 'bfhskjf94589', and after
the chdir, the open() would've tried to open $tmpdir/$tmpdir/foo.

Note that this is only the case when not running in taint mode.  If taint
is enabled, ->tmpdir will still return '.'; this mirrors the behavior of
File::Temp.
dist/PathTools/Cwd.pm
dist/PathTools/lib/File/Spec.pm
dist/PathTools/lib/File/Spec/Cygwin.pm
dist/PathTools/lib/File/Spec/Epoc.pm
dist/PathTools/lib/File/Spec/OS2.pm
dist/PathTools/lib/File/Spec/Unix.pm
dist/PathTools/lib/File/Spec/VMS.pm
dist/PathTools/t/tmpdir.t