2002-12-12 00:10:17 +03:00
|
|
|
#! @PERL@ -w
|
2002-12-09 23:16:34 +03:00
|
|
|
#
|
|
|
|
# Written by Adam Byrtek <alpha@debian.org>, 2002
|
2009-05-14 15:30:45 +04:00
|
|
|
# Rewritten by David Sterba <dave@jikos.cz>, 2009
|
2003-01-13 15:07:45 +03:00
|
|
|
#
|
2003-03-11 10:14:03 +03:00
|
|
|
# Extfs to handle patches in context and unified diff format.
|
|
|
|
# Known issues: When name of file to patch is modified during editing,
|
|
|
|
# hunk is duplicated on copyin. It is unavoidable.
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-12-19 21:20:11 +03:00
|
|
|
use bytes;
|
2002-12-09 23:16:34 +03:00
|
|
|
use strict;
|
2002-12-19 21:20:11 +03:00
|
|
|
use POSIX;
|
2003-02-26 18:08:37 +03:00
|
|
|
use File::Temp 'tempfile';
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-12-09 23:16:34 +03:00
|
|
|
# standard binaries
|
2009-01-24 08:11:35 +03:00
|
|
|
my $lzma = 'lzma';
|
2009-05-12 06:00:51 +04:00
|
|
|
my $xz = 'xz';
|
2003-01-13 15:07:45 +03:00
|
|
|
my $bzip = 'bzip2';
|
|
|
|
my $gzip = 'gzip';
|
2003-03-11 10:14:03 +03:00
|
|
|
my $fileutil = 'file';
|
2000-09-18 18:25:47 +04:00
|
|
|
|
2002-12-09 23:16:34 +03:00
|
|
|
# date parsing requires Date::Parse from TimeDate module
|
2003-02-26 18:08:37 +03:00
|
|
|
my $parsedates = eval 'require Date::Parse';
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-01-13 15:07:45 +03:00
|
|
|
# regular expressions
|
2009-05-14 15:30:45 +04:00
|
|
|
my $unified_header=qr/^--- .*\n\+\+\+ .*\n$/;
|
2003-01-13 15:07:45 +03:00
|
|
|
my $unified_extract=qr/^--- ([^\s]+).*\n\+\+\+ ([^\s]+)\s*([^\t\n]*)/;
|
2003-03-27 19:10:42 +03:00
|
|
|
my $unified_contents=qr/^([+\-\\ \n]|@@ .* @@)/;
|
2009-05-14 15:30:45 +04:00
|
|
|
my $unified_hunk=qr/@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+)) @@.*\n/;
|
2003-01-13 15:07:45 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
my $context_header=qr/^\*\*\* .*\n--- .*\n$/;
|
2003-01-13 15:07:45 +03:00
|
|
|
my $context_extract=qr/^\*\*\* ([^\s]+).*\n--- ([^\s]+)\s*([^\t\n]*)/;
|
2003-03-27 19:10:42 +03:00
|
|
|
my $context_contents=qr/^([!+\-\\ \n]|-{3} .* -{4}|\*{3} .* \*{4}|\*{15})/;
|
2003-01-13 15:07:45 +03:00
|
|
|
|
|
|
|
my $ls_extract_id=qr/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/;
|
|
|
|
my $basename=qr|^(.*/)*([^/]+)$|;
|
|
|
|
|
2004-11-17 02:00:40 +03:00
|
|
|
sub patchfs_canonicalize_path ($) {
|
|
|
|
my ($fname) = @_;
|
|
|
|
$fname =~ s,/+,/,g;
|
|
|
|
$fname =~ s,(^|/)(?:\.?\./)+,$1,;
|
|
|
|
return $fname;
|
|
|
|
}
|
2002-12-13 07:42:08 +03:00
|
|
|
|
|
|
|
# output unix date in a mc-readable format
|
2002-12-09 23:16:34 +03:00
|
|
|
sub timef
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2002-12-09 23:16:34 +03:00
|
|
|
my @time=localtime($_[0]);
|
2003-02-26 18:08:37 +03:00
|
|
|
return sprintf '%02d-%02d-%02d %02d:%02d', $time[4]+1, $time[3],
|
2002-12-13 08:08:14 +03:00
|
|
|
$time[5]+1900, $time[2], $time[1];
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-12-13 07:42:08 +03:00
|
|
|
# parse given string as a date and return unix time
|
2002-12-09 23:16:34 +03:00
|
|
|
sub datetime
|
|
|
|
{
|
|
|
|
# in case of problems fall back to 0 in unix time
|
|
|
|
# note: str2time interprets some wrong values (eg. " ") as 'today'
|
|
|
|
if ($parsedates && defined (my $t=str2time($_[0]))) {
|
2002-12-13 08:22:09 +03:00
|
|
|
return timef($t);
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
2002-12-13 08:22:09 +03:00
|
|
|
return timef(time);
|
2002-12-13 07:42:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# print message on stderr and exit
|
|
|
|
sub error
|
|
|
|
{
|
2002-12-19 19:51:04 +03:00
|
|
|
print STDERR $_[0], "\n";
|
2002-12-13 07:42:08 +03:00
|
|
|
exit 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2003-02-26 18:08:37 +03:00
|
|
|
# (compressed) input
|
|
|
|
sub myin
|
|
|
|
{
|
|
|
|
my ($qfname)=(quotemeta $_[0]);
|
|
|
|
|
2003-03-11 10:14:03 +03:00
|
|
|
$_=`$fileutil $qfname`;
|
2009-01-24 08:11:35 +03:00
|
|
|
if (/lzma/) {
|
|
|
|
return "$lzma -dc $qfname";
|
2009-05-12 06:00:51 +04:00
|
|
|
} elsif (/xz/) {
|
|
|
|
return "$xz -dc $qfname";
|
2009-01-24 08:11:35 +03:00
|
|
|
} elsif (/bzip/) {
|
2003-02-26 18:08:37 +03:00
|
|
|
return "$bzip -dc $qfname";
|
|
|
|
} elsif (/gzip/) {
|
|
|
|
return "$gzip -dc $qfname";
|
|
|
|
} else {
|
|
|
|
return "cat $qfname";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# (compressed) output
|
|
|
|
sub myout
|
|
|
|
{
|
|
|
|
my ($qfname,$append)=(quotemeta $_[0],$_[1]);
|
|
|
|
my ($sep) = $append ? '>>' : '>';
|
|
|
|
|
2003-03-11 10:14:03 +03:00
|
|
|
$_=`$fileutil $qfname`;
|
2009-01-24 08:11:35 +03:00
|
|
|
if (/lzma/) {
|
|
|
|
return "$lzma -c $sep $qfname";
|
2009-05-12 06:00:51 +04:00
|
|
|
} elsif (/xz/) {
|
|
|
|
return "$xz -c $sep $qfname";
|
2009-01-24 08:11:35 +03:00
|
|
|
} elsif (/bzip/) {
|
2003-02-26 18:08:37 +03:00
|
|
|
return "$bzip -c $sep $qfname";
|
|
|
|
} elsif (/gzip/) {
|
|
|
|
return "$gzip -c $sep $qfname";
|
|
|
|
} else {
|
|
|
|
return "cat $sep $qfname";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# select diff filename conforming with rules found in diff.info
|
|
|
|
sub diff_filename
|
|
|
|
{
|
2004-11-17 02:00:40 +03:00
|
|
|
my ($fsrc,$fdst)= @_;
|
2009-05-14 15:30:45 +04:00
|
|
|
# TODO: can remove these two calls later
|
2004-11-17 02:00:40 +03:00
|
|
|
$fsrc = patchfs_canonicalize_path ($fsrc);
|
|
|
|
$fdst = patchfs_canonicalize_path ($fdst);
|
2003-02-26 18:08:37 +03:00
|
|
|
if (!$fdst && !$fsrc) {
|
|
|
|
error 'Index: not yet implemented';
|
|
|
|
} elsif (!$fsrc || $fsrc eq '/dev/null') {
|
|
|
|
return ($fdst,'PATCH-CREATE/');
|
|
|
|
} elsif (!$fdst || $fdst eq '/dev/null') {
|
|
|
|
return ($fsrc,'PATCH-REMOVE/');
|
|
|
|
} elsif (($fdst eq '/dev/null') && ($fsrc eq '/dev/null')) {
|
|
|
|
error 'Malformed diff';
|
|
|
|
} else {
|
|
|
|
# fewest path name components
|
|
|
|
if ($fdst=~s|/|/|g < $fsrc=~s|/|/|g) {
|
|
|
|
return ($fdst,'');
|
|
|
|
} elsif ($fdst=~s|/|/|g > $fsrc=~s|/|/|g) {
|
|
|
|
return ($fsrc,'');
|
|
|
|
} else {
|
|
|
|
# shorter base name
|
2009-05-14 15:30:45 +04:00
|
|
|
if (($fdst=~/$basename/o,length $2) < ($fsrc=~/$basename/o,length $2)) {
|
2003-02-26 18:08:37 +03:00
|
|
|
return ($fdst,'');
|
2009-05-14 15:30:45 +04:00
|
|
|
} elsif (($fdst=~/$basename/o,length $2) > ($fsrc=~/$basename/o,length $2)) {
|
2003-02-26 18:08:37 +03:00
|
|
|
return ($fsrc,'');
|
|
|
|
} else {
|
|
|
|
# shortest names
|
|
|
|
if (length $fdst < length $fsrc) {
|
|
|
|
return ($fdst,'');
|
|
|
|
} else {
|
|
|
|
return ($fsrc,'');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
# IN: diff "archive" name
|
|
|
|
# IN: file handle for output; STDIN for list, tempfile else
|
|
|
|
# IN: filename to watch (for: copyout, rm), '' for: list
|
|
|
|
# IN: remove the file?
|
|
|
|
# true - ... and print out the rest
|
|
|
|
# false - ie. copyout mode, print just the file
|
|
|
|
sub parse($$$$)
|
2003-02-26 18:08:37 +03:00
|
|
|
{
|
2009-05-14 15:30:45 +04:00
|
|
|
my $archive=quotemeta shift;
|
|
|
|
my $fh=shift;
|
|
|
|
my $file=shift;
|
|
|
|
my $rmmod=shift;
|
|
|
|
my ($state,$fsize,$time);
|
2002-12-13 07:42:08 +03:00
|
|
|
my ($f,$fsrc,$fdst,$prefix);
|
2009-05-14 15:30:45 +04:00
|
|
|
my ($unified,$context);
|
|
|
|
my ($skipread, $filetoprint, $filefound);
|
|
|
|
my ($h_add,$h_del,$h_ctx); # hunk line counts
|
|
|
|
my ($h_r1,$h_r2); # hunk ranges
|
|
|
|
my @outsrc; # if desired ...
|
|
|
|
my @outdst;
|
|
|
|
my $line;
|
2002-12-13 07:42:08 +03:00
|
|
|
|
|
|
|
# use uid and gid from file
|
2009-05-14 15:30:45 +04:00
|
|
|
my ($uid,$gid)=(`ls -l $archive`=~/$ls_extract_id/o);
|
2002-12-09 23:16:34 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
import Date::Parse if ($parsedates && $file eq '');
|
2003-01-13 15:07:45 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
$line=1;
|
|
|
|
$state=0; $fsize=0; $f='';
|
|
|
|
$filefound=0;
|
|
|
|
while ($skipread || ($line++,$_=<I>)) {
|
|
|
|
$skipread=0;
|
|
|
|
if($state == 0) { # expecting comments
|
|
|
|
$unified=$context=0;
|
2003-01-13 15:07:45 +03:00
|
|
|
$unified=1 if (/^--- /);
|
|
|
|
$context=1 if (/^\*\*\* /);
|
|
|
|
if (!$unified && !$context) {
|
2009-05-14 15:30:45 +04:00
|
|
|
$filefound=0 if($file ne '' && $filetoprint);
|
|
|
|
# shortcut for rmmod xor filefound
|
|
|
|
# - in rmmod we print if not found
|
|
|
|
# - in copyout (!rmmod) we print if found
|
|
|
|
print $fh $_ if($rmmod != $filefound);
|
2003-01-13 15:07:45 +03:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
if($file eq '' && $filetoprint) {
|
|
|
|
printf $fh "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $fsize, datetime($time), $prefix, $f;
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
2002-12-13 07:42:08 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
# start of new file
|
|
|
|
$_ .=<I>; # steel next line, both formats
|
|
|
|
$line++;
|
|
|
|
if($unified) {
|
|
|
|
if(/$unified_header/o) {
|
|
|
|
($fsrc,$fdst,$time) = /$unified_extract/o;
|
|
|
|
} else {
|
|
|
|
error "Can't parse unified diff header";
|
|
|
|
}
|
|
|
|
} elsif($context) {
|
|
|
|
if(/$context_header/o) {
|
|
|
|
($fsrc,$fdst,$time) = /$context_extract/o;
|
|
|
|
} else {
|
|
|
|
error "Can't parse context diff header";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error "Unrecognized diff header";
|
|
|
|
}
|
|
|
|
$fsrc=patchfs_canonicalize_path($fsrc);
|
|
|
|
$fdst=patchfs_canonicalize_path($fdst);
|
|
|
|
if(wantarray) {
|
|
|
|
push @outsrc,$fsrc;
|
|
|
|
push @outdst,$fdst;
|
|
|
|
}
|
2003-02-26 18:08:37 +03:00
|
|
|
($f,$prefix)=diff_filename($fsrc,$fdst);
|
2009-05-14 15:30:45 +04:00
|
|
|
$filefound=($fsrc eq $file || $fdst eq $file);
|
2002-12-13 07:42:08 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
$f="$f.diff";
|
|
|
|
$filetoprint=1;
|
|
|
|
$fsize=length;
|
|
|
|
print $fh $_ if($rmmod != $filefound);
|
2003-01-13 15:07:45 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
$state=1;
|
|
|
|
} elsif($state == 1) { # expecting diff hunk headers, end of file or comments
|
|
|
|
if($unified) {
|
|
|
|
my ($a,$b,$c,$d);
|
|
|
|
($a,$b,$h_r1,$c,$d,$h_r2)=/$unified_hunk/o;
|
|
|
|
if(!defined($a) || !defined($c)) {
|
|
|
|
# hunk header does not come, a comment inside
|
|
|
|
# or maybe a new file, state 0 will decide
|
|
|
|
$skipread=1;
|
|
|
|
$state=0;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
$fsize+=length;
|
|
|
|
print $fh $_ if($rmmod != $filefound);
|
|
|
|
$h_r1=1 if(!defined($b));
|
|
|
|
$h_r2=1 if(!defined($d));
|
|
|
|
$h_add=$h_del=$h_ctx=0;
|
|
|
|
$state=2;
|
|
|
|
} elsif($context) {
|
|
|
|
if(!/$context_contents/o) {
|
|
|
|
$skipread=1;
|
|
|
|
$state=0;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
print $fh $_ if($rmmod != $filefound);
|
|
|
|
$fsize+=length;
|
|
|
|
}
|
|
|
|
} elsif($state == 2) { # expecting hunk contents
|
|
|
|
if($h_del + $h_ctx == $h_r1 && $h_add + $h_ctx == $h_r2) {
|
|
|
|
# hooray, end of hunk
|
|
|
|
# we optimistically ended with a hunk before but
|
|
|
|
# the line has been read already
|
|
|
|
$skipread=1;
|
|
|
|
$state=1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
print $fh $_ if($rmmod != $filefound);
|
|
|
|
$fsize+=length;
|
|
|
|
my ($first)= /^(.)/;
|
|
|
|
if(ord($first) == ord('+')) { $h_add++; }
|
|
|
|
elsif(ord($first) == ord('-')) { $h_del++; }
|
|
|
|
elsif(ord($first) == ord(' ')) { $h_ctx++; }
|
|
|
|
elsif(ord($first) == ord('\\')) { 0; }
|
|
|
|
elsif(ord($first) == ord('@')) { error "Malformed hunk, header came too early"; }
|
|
|
|
else { error "Unrecognized character in hunk"; }
|
|
|
|
}
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
2009-05-14 15:30:45 +04:00
|
|
|
if($file eq '' && $filetoprint) {
|
|
|
|
printf $fh "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $fsize, datetime($time), $prefix, $f;
|
|
|
|
}
|
|
|
|
|
|
|
|
close($fh) if($file ne '');
|
|
|
|
return \(@outsrc, @outdst) if wantarray;
|
|
|
|
}
|
|
|
|
|
|
|
|
# list files affected by patch
|
|
|
|
sub list($) {
|
|
|
|
parse($_[0], *STDOUT, '', 0);
|
|
|
|
close(I);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2003-01-13 15:07:45 +03:00
|
|
|
# extract diff from patch
|
2009-05-14 15:30:45 +04:00
|
|
|
# IN: diff file to find
|
|
|
|
# IN: output file name
|
|
|
|
sub copyout($$) {
|
2002-12-09 23:16:34 +03:00
|
|
|
my ($file,$out)=@_;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-12-13 07:42:08 +03:00
|
|
|
$file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/;
|
2004-11-17 02:00:40 +03:00
|
|
|
$file = patchfs_canonicalize_path ($file);
|
2003-01-13 15:07:45 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
open(FH, ">$out") or error("Cannot open output file");
|
|
|
|
parse('', *FH, $file, 0);
|
2002-12-13 07:42:08 +03:00
|
|
|
}
|
2002-12-09 23:16:34 +03:00
|
|
|
|
2003-02-26 18:08:37 +03:00
|
|
|
# remove diff(s) from patch
|
2009-05-14 15:30:45 +04:00
|
|
|
# IN: archive
|
|
|
|
# IN: file to delete
|
|
|
|
sub rm($$) {
|
|
|
|
my $archive=shift;
|
2003-02-26 18:08:37 +03:00
|
|
|
my ($tmp,$tmpname)=tempfile();
|
2002-12-13 07:42:08 +03:00
|
|
|
|
2003-02-26 18:08:37 +03:00
|
|
|
@_=map {scalar(s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/,$_)} @_;
|
2002-12-13 07:42:08 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
# just the first file for now
|
|
|
|
parse($archive, $tmp, $_[0], 1);
|
2003-02-26 18:08:37 +03:00
|
|
|
close I;
|
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
# replace archive
|
|
|
|
system("cat \Q$tmpname\E | " . myout($archive,0))==0
|
2003-02-26 18:08:37 +03:00
|
|
|
or error "Can't write to archive";
|
2009-05-14 15:30:45 +04:00
|
|
|
system("rm -f -- \Q$tmpname\E");
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-02-26 18:08:37 +03:00
|
|
|
# append diff to archive
|
2009-05-14 15:30:45 +04:00
|
|
|
# IN: diff archive name
|
|
|
|
# IN: newly created file name in archive
|
|
|
|
# IN: the real source file
|
|
|
|
sub copyin($$$) {
|
|
|
|
# TODO: seems to be tricky. what to do?
|
|
|
|
# copyin of file which is already there may:
|
|
|
|
# * delete the original and copy only the new
|
|
|
|
# * just append the new hunks to the same file
|
|
|
|
# problems: may not be a valid diff, unmerged hunks
|
|
|
|
# * try to merge the two together
|
|
|
|
# ... but we do not want write patchutils again, right?
|
|
|
|
error "Copying files into diff not supported";
|
|
|
|
return;
|
|
|
|
|
|
|
|
my ($archive,$name,$src)=@_;
|
|
|
|
|
|
|
|
# in case we are appending another diff, we have
|
|
|
|
# to delete/merge all the files
|
|
|
|
open(DEVNULL, ">/dev/null");
|
2003-02-26 18:08:37 +03:00
|
|
|
open I, myin($src).'|';
|
2009-05-14 15:30:45 +04:00
|
|
|
my ($srclist,$dstlist)=parse($archive, *DEVNULL, '', 0);
|
|
|
|
close(I);
|
|
|
|
close(DEVNULL);
|
|
|
|
foreach(@$srclist) {
|
|
|
|
print("SRC: del $_\n");
|
2002-12-13 07:42:08 +03:00
|
|
|
}
|
2009-05-14 15:30:45 +04:00
|
|
|
foreach(@$dstlist) {
|
|
|
|
print("DST: del $_\n");
|
|
|
|
}
|
|
|
|
return;
|
2003-02-26 18:08:37 +03:00
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
# remove overwritten file
|
2003-02-26 18:08:37 +03:00
|
|
|
open I, myin($archive).'|';
|
2009-05-14 15:30:45 +04:00
|
|
|
rm ($archive, $name);
|
2003-02-26 18:08:37 +03:00
|
|
|
close I;
|
|
|
|
|
2009-05-14 15:30:45 +04:00
|
|
|
my $cmd1=myin("$src.diff");
|
2003-03-11 10:14:03 +03:00
|
|
|
my $cmd2=myout($archive,1);
|
2003-02-26 18:08:37 +03:00
|
|
|
system("$cmd1 | $cmd2")==0
|
|
|
|
or error "Can't write to archive";
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-12-13 07:42:08 +03:00
|
|
|
|
2003-01-13 15:07:45 +03:00
|
|
|
if ($ARGV[0] eq 'list') {
|
2003-02-26 18:08:37 +03:00
|
|
|
open I, myin($ARGV[1]).'|';
|
2009-05-14 15:30:45 +04:00
|
|
|
list ($ARGV[1]);
|
2002-12-13 07:42:08 +03:00
|
|
|
exit 0;
|
2004-08-19 19:43:09 +04:00
|
|
|
} elsif ($ARGV[0] eq 'copyout') {
|
2003-02-26 18:08:37 +03:00
|
|
|
open I, myin($ARGV[1])."|";
|
2002-12-09 23:16:34 +03:00
|
|
|
copyout ($ARGV[2], $ARGV[3]);
|
2002-12-13 07:42:08 +03:00
|
|
|
exit 0;
|
2004-08-19 19:43:09 +04:00
|
|
|
} elsif ($ARGV[0] eq 'rm') {
|
2003-02-26 18:08:37 +03:00
|
|
|
open I, myin($ARGV[1])."|";
|
|
|
|
rm ($ARGV[1], $ARGV[2]);
|
|
|
|
exit 0;
|
2004-08-19 19:43:09 +04:00
|
|
|
} elsif ($ARGV[0] eq 'rmdir') {
|
2003-02-26 18:08:37 +03:00
|
|
|
exit 0;
|
2004-08-19 19:43:09 +04:00
|
|
|
} elsif ($ARGV[0] eq 'mkdir') {
|
2003-02-26 18:08:37 +03:00
|
|
|
exit 0;
|
2004-08-19 19:43:09 +04:00
|
|
|
} elsif ($ARGV[0] eq 'copyin') {
|
2002-12-13 07:42:08 +03:00
|
|
|
copyin ($ARGV[1], $ARGV[2], $ARGV[3]);
|
|
|
|
exit 0;
|
2002-12-09 23:16:34 +03:00
|
|
|
}
|
2002-12-13 07:42:08 +03:00
|
|
|
exit 1;
|