blob: b79776a4ebdc97fa6fa0d7cf33b9ba53846d82f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/usr/bin/perl
# $Header: /home/cvs/386BSD/ports/lang/perl/eg/van/vanish,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
sub it {
if ($olddir ne '.') {
chop($pwd = `pwd`) if $pwd eq '';
(chdir $olddir) || die "Directory $olddir is not accesible";
}
if (!-d .deleted) {
print `mkdir .deleted; chmod 775 .deleted`;
die "You can't remove files from $olddir" if $?;
}
$filelist =~ s/ $//;
$filelist =~ s/#/\\#/g;
if ($filelist !~ /^[ \t]*$/) {
open(lastcmd,'>.deleted/.lastcmd');
print lastcmd $filelist,"\n";
close(lastcmd);
print `/bin/mv $startfiles$filelist .deleted$force`;
}
if ($olddir ne '.') {
(chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
}
}
while ($ARGV[0] =~ /^-/) {
$_ = shift;
/^-f/ && ($force = ' >/dev/null 2>&1');
/^-i/ && ($interactive = 1);
if (/^-+$/) {
$startfiles = '- ';
last;
}
}
chop($pwd = `pwd`);
while ($file = shift) {
if ($file =~ s|^(.*)/||) {
$dir = $1;
}
else {
$dir = '.';
}
if ($interactive) {
print "vanish: remove $dir/$file? ";
next unless <stdin> =~ /^y/i;
}
if ($file eq '.deleted') {
print stderr "To delete .deleted (the trashcan) use the 'empty' command.\n";
next;
}
if ($dir ne $olddir) {
do it() if $olddir;
$olddir = $dir;
}
$filelist .= $file; $filelist .= ' ';
}
do it() if $olddir;
|