summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-11-03 13:28:08 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-11-03 13:28:08 +0000
commit9d47f02deb1678a80669616ca5666b0e3fbf1c17 (patch)
tree2072edac5ef847a9d24bd233b9f7e615320800b0 /usr.sbin/pkg_add
parent03249ed9de50c3a1be7446da20a771ba3f856200 (diff)
kludge: avoid creating non-empty files.
I don't like the fix, but it works...
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageLocator.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
index 58fe47361bc..337838a28e7 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageLocator.pm,v 1.47 2005/11/02 22:26:51 espie Exp $
+# $OpenBSD: PackageLocator.pm,v 1.48 2005/11/03 13:28:07 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -364,6 +364,7 @@ sub pkg_copy
kill $sig, $$;
};
+ my $nonempty = 0;
{
local $SIG{'PIPE'} = $handler;
@@ -380,13 +381,20 @@ sub pkg_copy
if (!defined $n) {
die "Error reading\n";
}
+ if ($n > 0) {
+ $nonempty = 1;
+ }
syswrite $copy, $buffer;
syswrite STDOUT, $buffer;
} while ($n != 0);
close($copy);
}
- rename $filename, "$dir/$name";
+ if ($nonempty) {
+ rename $filename, "$dir/$name";
+ } else {
+ unlink $filename;
+ }
}
sub open_pipe