You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
838 B
45 lines
838 B
#!/usr/bin/perl
|
|
|
|
# $RCSfile: empty,v $$Revision: 4.1 $$Date: 92/08/07 17:20:50 $
|
|
|
|
# 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(' ',@_));
|
|
}
|
|
|