don’t use File::Temp because it’s Perl >= 5.6.1 only

spotted by RT
This commit is contained in:
tg 2013-11-30 17:11:06 +00:00
parent 7cae22ef5c
commit 6e1ab32be6
1 changed files with 21 additions and 12 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.pl,v 1.32 2013/07/21 18:35:56 tg Exp $
# $MirOS: src/bin/mksh/check.pl,v 1.33 2013/11/30 17:11:06 tg Exp $
# $OpenBSD: th,v 1.16 2013/06/14 20:52:08 millert Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
@ -172,7 +172,6 @@ BEGIN {
use Getopt::Std;
use Config;
use File::Temp qw/ :mktemp /;
$os = defined $^O ? $^O : 'unknown';
@ -251,7 +250,7 @@ die "$prog: no test set specified (use -s)\n" if !defined $opt_s;
$test_prog = $opt_p;
$verbose = defined $opt_v && $opt_v;
$test_set = $opt_s;
$temp_dir = $opt_T || "/tmp";
$temp_base = $opt_T || "/tmp";
if (defined $opt_t) {
die "$prog: bad -t argument (should be number > 0): $opt_t\n"
if $opt_t !~ /^\d+$/ || $opt_t <= 0;
@ -300,6 +299,18 @@ chop($pwd = `pwd 2>/dev/null`);
die "$prog: couldn't get current working directory\n" if $pwd eq '';
die "$prog: couldn't cd to $pwd - $!\n" if !chdir($pwd);
die "$prog: couldn't cd to $temp_base - $!\n" if !chdir($temp_base);
die "$prog: couldn't get temporary directory base\n" unless -d '.';
$temps = sprintf("chk%d-%d.", $$, time());
$tempi = 0;
until (mkdir(($tempdir = sprintf("%s%03d", $temps, $tempi)), 0700)) {
die "$prog: couldn't get temporary directory\n" if $tempi++ >= 999;
}
die "$prog: couldn't cd to $tempdir - $!\n" if !chdir($tempdir);
chop($temp_dir = `pwd 2>/dev/null`);
die "$prog: couldn't get temporary directory\n" if $temp_dir eq '';
die "$prog: couldn't cd to $pwd - $!\n" if !chdir($pwd);
if (!$program_kludge) {
$test_prog = "$pwd/$test_prog" if substr($test_prog, 0, 1) ne '/';
die "$prog: $test_prog is not executable - bye\n"
@ -314,15 +325,12 @@ $SIG{'ALRM'} = 'catch_sigalrm';
$| = 1;
# Create temp files
($fh, $temps) = mkstemp("${temp_dir}/rts.XXXXXXXX");
close($fh);
($fh, $tempi) = mkstemp("${temp_dir}/rti.XXXXXXXX");
close($fh);
($fh, $tempo) = mkstemp("${temp_dir}/rto.XXXXXXXX");
close($fh);
($fh, $tempe) = mkstemp("${temp_dir}/rte.XXXXXXXX");
close($fh);
$tempdir = mkdtemp("${temp_dir}/rtd.XXXXXXXX");
$temps = "${temp_dir}/rts";
$tempi = "${temp_dir}/rti";
$tempo = "${temp_dir}/rto";
$tempe = "${temp_dir}/rte";
$tempdir = "${temp_dir}/rtd";
mkdir($tempdir, 0700) or die "$prog: couldn't mkdir $tempdir - $!\n";
if (-d $test_set) {
$file_prefix_skip = length($test_set) + 1;
@ -365,6 +373,7 @@ cleanup_exit
unlink($tempi, $tempo, $tempe, $temps);
&scrub_dir($tempdir) if defined $tempdir;
rmdir($tempdir) if defined $tempdir;
rmdir($temp_dir) if defined $temp_dir;
if ($sig) {
$SIG{$sig} = 'DEFAULT';