summaryrefslogtreecommitdiff
path: root/misc/mc/files/patch-vfs-extfs-a.in
blob: 07a5517329e18994e16666d35496c9404d96a9db (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--- vfs/extfs/a.in.orig	Thu Dec 12 02:57:00 2002
+++ vfs/extfs/a.in	Fri Sep 10 16:09:30 2004
@@ -8,6 +8,13 @@
 # 
 
 # These mtools components must be in PATH for this to work
+
+sub quote {
+    $_ = shift(@_);
+    s/([^\w\/.+-])/\\$1/g;
+    return($_);
+}
+
 $mmd = "mmd";
 $mrd = "mrd";
 $mdel = "mdel";
@@ -15,7 +22,7 @@
 $mcopy = "mcopy -noQ";
 
 $0 =~ s|.*/||;
-$disk = $0;
+$qdisk = quote($0);
 
 $ENV{MTOOLS_DATE_STRING} = "mm-dd-yyyy";
 $ENV{MTOOLS_TWENTY_FOUR_HOUR_CLOCK} = "1";
@@ -29,29 +36,36 @@
   /mkdir/ && do {
     shift; shift;
     exit 1 if scalar(@ARGV) != 1;
-    system("$mmd $disk:/$ARGV[0] >/dev/null");
+    $qname = quote($ARGV[0]);
+    system("$mmd $qdisk:/$qname >/dev/null");
     exit 0; };
   /rmdir/ && do {
     shift; shift;
     exit 1 if scalar(@ARGV) != 1;
-    system("$mrd $disk:/$ARGV[0] >/dev/null");
+    $qname = quote($ARGV[0]);
+    system("$mrd $qdisk:/$qname >/dev/null");
     exit 0; };
   /rm/ && do {
     shift; shift;
     exit 1 if scalar(@ARGV) != 1;
-    system("$mdel $disk:/$ARGV[0] >/dev/null");
+    $qname = quote($ARGV[0]);
+    system("$mdel $qdisk:/$qname >/dev/null");
     exit 0; };
   /copyout/ && do {
     shift; shift;
     exit 1 if scalar(@ARGV) != 2;
-    ( $src, $dest ) = @ARGV;
-    system("$mcopy $disk:/$src $dest >/dev/null");
+    ( $qsrc, $qdest ) = @ARGV;
+    $qsrc = quote($qsrc);
+    $qdest = quote($qdest);
+    system("$mcopy $qdisk:/$qsrc $qdest >/dev/null");
     exit 0; };
   /copyin/ && do {
     shift; shift;
     exit 1 if scalar(@ARGV) != 2;
-    ( $dest, $src ) = @ARGV;
-    system("$mcopy $src $disk:/$dest >/dev/null");
+    ( $qdest, $qsrc ) = @ARGV;
+    $qsrc = quote($qsrc);
+    $qdest = quote($qdest);
+    system("$mcopy $qsrc $qdisk:/$qdest >/dev/null");
     exit 0; };
   /.*/ && do {                               # an unfamiliar command
     exit 1; };
@@ -59,11 +73,11 @@
 
 sub get_dirs {
   my ($path, $name, $size, $date, $time, $longname, @lst, @rv);
-
   $path = shift(@_);
+  my $qpath = quote($path);
   @rv = ();
 
-  open(FILE,"$mdir $disk:/$path |");
+  open(FILE,"$mdir $qdisk:/$qpath |");
   while ( <FILE> ) {
     chomp();
     /^ / && next;                            # ignore `non-file' lines