summaryrefslogtreecommitdiff
path: root/eg/van/empty
diff options
context:
space:
mode:
Diffstat (limited to 'eg/van/empty')
-rw-r--r--eg/van/empty45
1 files changed, 45 insertions, 0 deletions
diff --git a/eg/van/empty b/eg/van/empty
new file mode 100644
index 0000000000..11a55583e1
--- /dev/null
+++ b/eg/van/empty
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+# $Header: empty,v 2.0 88/06/05 00:17:39 root Exp $
+
+# This script empties a trashcan.
+
+$recursive = shift if $ARGV[0] eq '-r';
+
+@ARGV = '.' if $#ARGV < 0;
+
+chop($pwd = `pwd`);
+
+dir: foreach $dir (@ARGV) {
+ unless (chdir $dir) {
+ print stderr "Can't find directory $dir\n";
+ next dir;
+ }
+ if ($recursive) {
+ do cmd('find . -name .deleted -exec /bin/rm -rf {} ;');
+ }
+ else {
+ if (-d '.deleted') {
+ do cmd('rm -rf .deleted');
+ }
+ else {
+ if ($dir eq '.' && $pwd =~ m|/\.deleted$|) {
+ chdir '..';
+ do cmd('rm -rf .deleted');
+ }
+ else {
+ print stderr "No trashcan found in directory $dir\n";
+ }
+ }
+ }
+}
+continue {
+ chdir $pwd;
+}
+
+# force direct execution with no shell
+
+sub cmd {
+ system split(' ',join(' ',@_));
+}
+