]> arthur.barton.de Git - netatalk.git/blob - contrib/shell_utils/apple_rm
small adaptations for CVS tree
[netatalk.git] / contrib / shell_utils / apple_rm
1 #! /usr/bin/perl
2
3 # $Header: /home/ralph/netatalk/rsync/netatalk/contrib/shell_utils/Attic/apple_rm,v 1.2 2000-08-09 14:12:06 rufustfirefly Exp $
4 #
5 # $Log: apple_rm,v $
6 # Revision 1.2  2000-08-09 14:12:06  rufustfirefly
7 # /usr/local/bin/perl -> /usr/bin/perl and portability fixes
8 #
9 # Revision 1.1  2000/08/09 14:08:06  rufustfirefly
10 # Shell utils from http://www.-genome.wi.mit.edu/ftp/distribution/software/Bass/bass-1.29/apple_util/ (initial import)
11 #
12 # Revision 1.1  1996/04/03 02:13:14  lstein
13 # Added all these files because they're essential utilities.
14 #
15 # Revision 1.1  1996/02/09  18:21:35  will
16 # Initial revision
17 #
18 #
19
20 $USAGE = <<USAGE;
21 Usage: $0 filename ...
22 Do an apple remove, remove the resource fork as well
23 USAGE
24
25 die $USAGE if @ARGV < 1;
26
27 foreach $path (@ARGV) {
28     if (!-f $path) {
29         print STDERR "file $path does not exist\n";
30         die $USAGE;
31     }
32
33     ($dir, $file) = &split_dir_file($path);
34
35     $cmd = "rm '$path'";
36     system $cmd || die "error executing $cmd";
37     
38     $cmd = "rm '$dir/.AppleDouble/$file'";
39     system $cmd || die "error executing $cmd";
40 }
41
42 # split a file path into a directory and file name.
43 sub split_dir_file {
44     my $path = shift;
45
46     @path_elems = split(/\//, $path);
47
48     my $file = pop(@path_elems);
49     my $dir;
50     if (!@path_elems) {
51         $dir = '.';
52     } else {
53         $dir = join('/', @path_elems);
54     }
55
56     $dir, $file;
57 }