summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-06-21 13:23:10 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-06-21 13:23:10 +0000
commitb1b7d5ce1db67cf7638bd86d79dd02b5ac64df57 (patch)
treef611ce5039a58fb4e699803cc33e7b6d71a53851 /usr.sbin
parent68fe03813211a5c6843040938e0c01d8f403b830 (diff)
introduce unlink operation with nice properties
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Error.pm16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm
index 0f8d8d052fc..e791c295e4c 100644
--- a/usr.sbin/pkg_add/OpenBSD/Error.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Error.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Error.pm,v 1.12 2008/03/10 13:11:57 espie Exp $
+# $OpenBSD: Error.pm,v 1.13 2008/06/21 13:23:09 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -20,7 +20,7 @@ use warnings;
package OpenBSD::Error;
our @ISA=qw(Exporter);
-our @EXPORT=qw(System VSystem Copy Fatal Warn Usage set_usage
+our @EXPORT=qw(System VSystem Copy Unlink Fatal Warn Usage set_usage
try throw catch catchall rethrow);
our ($FileName, $Line, $FullMessage);
@@ -120,6 +120,18 @@ sub Copy
return $r;
}
+sub Unlink
+{
+ my $verbose = shift;
+ my $r = unlink @_;
+ if ($r != @_) {
+ print "rm @_ failed: removed only $r targets, $!\n";
+ } elsif ($verbose) {
+ print "rm @_\n";
+ }
+ return $r;
+}
+
sub Fatal
{
require Carp;