Re: New patchfs script



Hi, Adam!
Adam Byrtek 'alpha' wrote:
On Mon, Dec 09, 2002 at 12:16:42PM -0500, Pavel Roskin wrote:

I hope to put your script on CVS today and I'm ready to make fixes myself,
but I just want to give you are chance to do it right.

Updated version attached. It works in reasonable time, even with
kernel patches. It supports file size and date parsing. All warnings
fixed. I considered some 'run' virtual methods, but decided they are
redundant. 'patch -p1' is quite simple to type in fact... and one can
add it to mc menu if he wants.

I applied little patch for your patchfs to quote metacharacters in 
filename before giving it to shell.  Also I want to eliminate temporary 
file in copyout() and teach patchfs to understand context diffs (diff -c).
Another good change should be to use +++ filename for newly created 
files (--- /dev/null).
And it is reasonable to search and substitute perl in patchfs, a and 
uzip scripts, but this is another story.
--
Regards,
Andrew V. Samoilov
Index: patchfs
===================================================================
RCS file: /cvs/gnome/mc/vfs/extfs/patchfs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- patchfs	9 Dec 2002 20:16:34 -0000	1.6
+++ patchfs	11 Dec 2002 11:03:26 -0000	1.7
@@ -124,14 +124,15 @@
 
 
 my $tmp;
-$_=`$file $ARGV[1]`;
+my $quoted_name = quotemeta $ARGV[1];
+$_=`$file $quoted_name`;
 if (/bzip/) {
     $tmp=tmpnam();
-    system "$bzcat $ARGV[1] > $tmp";
+    system "$bzcat $quoted_name > $tmp";
     open I, "< $tmp";
 } elsif (/gzip/) {
     $tmp=tmpnam();
-    system "$gzcat $ARGV[1] > $tmp";
+    system "$gzcat $quoted_name > $tmp";
     open I, "< $tmp";
 } else {
     open I, "< $ARGV[1]";
@@ -141,7 +142,7 @@
     list;
     exit(0);
 } if ($ARGV[0] eq "copyout") {
-    copyout ($ARGV[2], $ARGV[3]);
+    copyout ($ARGV[2], quotemeta ($ARGV[3]));
     exit(0);
 }
 exit(1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]