about summary refs log tree commit diff
path: root/Util
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2007-12-04 01:40:18 +0000
committerWayne Davison <wayned@users.sourceforge.net>2007-12-04 01:40:18 +0000
commita58d1187535d04e1757083ed1529d7f4c1e38ac8 (patch)
tree67ebdc97a99e8ce913e71205fb0234470af7e537 /Util
parent61320c44c1c09a1e9b455771437c94174108739c (diff)
downloadzsh-a58d1187535d04e1757083ed1529d7f4c1e38ac8.tar.gz
zsh-a58d1187535d04e1757083ed1529d7f4c1e38ac8.tar.xz
zsh-a58d1187535d04e1757083ed1529d7f4c1e38ac8.zip
24147
Diffstat (limited to 'Util')
-rw-r--r--Util/difflog.pl19
1 files changed, 9 insertions, 10 deletions
diff --git a/Util/difflog.pl b/Util/difflog.pl
index 9872ded69..ff2d4bc16 100644
--- a/Util/difflog.pl
+++ b/Util/difflog.pl
@@ -2,10 +2,9 @@
 
 use strict;
 use IO::File;
+use File::Temp qw(tempfile);
 
 my @differ = qw(diff -bw);
-my $oldtmp = "/tmp/difflog$$.old";
-my $newtmp = "/tmp/difflog$$.new";
 
 my $newfn = pop(@ARGV);
 my $oldfn = pop(@ARGV);
@@ -36,16 +35,16 @@ while ($old < @oldentries && $new < @newentries)
   else
   {
     if ($oldhash{$oldentries[$old]} ne $newhash{$newentries[$new]}) {
-      my $oldfh = new IO::File("/tmp/difflog$$.old", 'w');
-      $oldfh->print($oldhash{$oldentries[$old]});
-      $oldfh->close();
-      my $newfh = new IO::File("/tmp/difflog$$.new", 'w');
-      $newfh->print($newhash{$newentries[$new]});
-      $newfh->close();
-      open(DIFF, join(' ', @differ, @ARGV, $oldtmp, $newtmp, '|'));
+      my($oldfh, $oldtmp) = tempfile('difflog-XXXXXXXX', SUFFIX => '.old', DIR => '/tmp');
+      print $oldfh $oldhash{$oldentries[$old]};
+      close($oldfh);
+      my($newfh, $newtmp) = tempfile('difflog-XXXXXXXX', SUFFIX => '.new', DIR => '/tmp');
+      print $newfh $newhash{$newentries[$new]};
+      close($newfh);
+      open(DIFF, '-|', @differ, @ARGV, $oldtmp, $newtmp) or die $!;
       my @lines = <DIFF>;
       close(DIFF);
-      unlink </tmp/difflog$$.*>;
+      unlink($oldtmp, $newtmp);
       if (@lines)
       {
 	print "diff for ", $oldentries[$old], ":\n";