[tex-live] TeX Live 2008 testing - problems downloading
George N. White III
gnwiii at gmail.com
Mon Jun 30 13:03:34 CEST 2008
Why not use Perl's File::Spec?:
From
tmpdir
Returns a string representation of the first writable directory
from a list of possible temporary directories. Returns "" if no
writable temporary directories are found. The list of directories
checked depends on the platform; e.g. File::Spec::Unix checks
$ENV{TMPDIR} and /tmp.
$tmpdir = File::Spec->tmpdir();
I tried this for linux and for wine's simulation of XP using the perl
from install-tl (with wine it is important
that TMPDIR not be set to the linux path, as perl will attempt to use
that). Wine gave c:\Windows\temp:
C:\install-tl> type try.cmd
@echo off
rem test of perl's tmpdir
set TMPDIR=
set tlroot=%~dp0
set tldrive=%~d0
%tldrive%
cd %tlroot%
rem we need wget in the path, so add tlpkg\bin to the path
set pathsave=%path%
path %tlroot%tlpkg\installer;%path%
rem use provided Perl
set PERL5SAVE=%PERL5LIB%
set PERL5LIB=%tlroot%tlpkg\installer\perllib
"%tlroot%tlpkg\installer\perl" %tlroot%try.pl
C:\install-tl>./try.cmd
testing File::Spec->tmpdir()
tmpdir: C:\windows\temp
C:\install-tl>type try.pl
#! /usr/bin/env perl
#tmpdir
# Returns a string representation of the first writable directory
# from a list of possible temporary directories. Returns "" if no
# writable temporary directories are found. The list of directories
# checked depends on the platform; e.g. File::Spec::Unix checks
# $ENV{TMPDIR} and /tmp.
use File::Spec;
print "testing File::Spec->tmpdir()\n";
$tmpdir = File::Spec->tmpdir();
print "tmpdir: $tmpdir\n";
On Mon, Jun 30, 2008 at 6:37 AM, Heiko Oberdiek
<oberdiek at uni-freiburg.de> wrote:
> On Sun, Jun 29, 2008 at 08:10:46PM +0200, Norbert Preining wrote:
>
>> On So, 29 Jun 2008, Karl Berry wrote:
>> > I'm surprised that perl doesn't respect TMPDIR.
>> >
>> > It's not about perl, it is about our code. And yes, it should use
>> > TMPDIR rather than hardwiring /tmp.
>>
>> It should do it ...
>>
>> code from TLUtils.pm:
>> sub get_system_tmpdir {
>> my $systmp=0;
>> $systmp||=getenv 'TMPDIR';
>> $systmp||=getenv 'TMP';
>> $systmp||=getenv 'TEMP';
>> $systmp||='/tmp';
>> return "$systmp";
>> }
>>
>> SO it tries first TMPDIR, then TMP, then TEMP, then /tmp ...
>
> I would add some sanity checks, e.g.:
>
> sub get_check_tmpdir {
> my $tmpdir = $_[0];
> -d $tmpdir or return '';
> -w $tmpdir or return '';
> -x $tmpdir or return '';
> $tmpdir;
> }
>
> sub get_system_tmpdir {
> my $systmp = '';
> $systmp ||= get_check_tmpdir getenv 'TMPDIR';
> $systmp ||= get_check_tmpdir getenv 'TMP';
> $systmp ||= get_check_tmpdir getenv 'TEMP';
> $systmp ||= '/tmp';
> }
>
> Yours sincerely
> Heiko <oberdiek at uni-freiburg.de>
>
--
George N. White III <aa056 at chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia
More information about the tex-live
mailing list