about summary refs log tree commit diff
path: root/scripts/nix-install-package.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nix-install-package.in')
-rw-r--r--scripts/nix-install-package.in8
1 files changed, 3 insertions, 5 deletions
diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in
index dc46c8cb22cb..bb72601ebd93 100644
--- a/scripts/nix-install-package.in
+++ b/scripts/nix-install-package.in
@@ -1,7 +1,7 @@
 #! @perl@ -w
 
 use strict;
-use POSIX qw(tmpnam);
+use File::Temp qw(tempdir);
 
 
 sub usageError {
@@ -65,10 +65,8 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) {
 }
 
 
-my $tmpDir;
-do { $tmpDir = tmpnam(); }
-until mkdir $tmpDir, 0777;
-END { if (defined $tmpDir) { my $x = $?; system("@coreutils@/rm", "-rf", $tmpDir); $? = $x; } }
+my $tmpDir = tempdir("nix-install-package.XXXXXX", CLEANUP => 1, TMPDIR => 1)
+    or die "cannot create a temporary directory";
 
 
 sub barf {