From 1bcce94a10f5994d6338d56940705261ca78e7ef Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 20 Jun 2016 09:56:38 +0200 Subject: [PATCH] pmirror: style: set opening brackets on same line (except subs) --- pmirror/pmirror | 365 +++++++++++++++--------------------------------- 1 file changed, 112 insertions(+), 253 deletions(-) diff --git a/pmirror/pmirror b/pmirror/pmirror index a64715a..a06d35a 100755 --- a/pmirror/pmirror +++ b/pmirror/pmirror @@ -73,8 +73,7 @@ sub export_index { my ($self)=@_; my $type=$self->type; - return - ( + return ( $type, fn_escape($self->name), $self->perm, @@ -94,8 +93,7 @@ sub import_index { my ($class,@F)=@_; my $type=$F[0]; - return bless - [ + return bless [ fn_unescape($F[1]), # name 0,0, # dev,ino $type, # type @@ -118,13 +116,11 @@ sub lstat my @f; no warnings 'newline'; - unless (@f=lstat $filename) - { + unless (@f=lstat $filename) { $!==2 and return undef; # ENOENT die "$filename: $!\n"; } - if (-l _) - { + if (-l _) { defined ($target=readlink($filename)) or die "$filename: $!\n"; } my $type = @@ -136,8 +132,7 @@ sub lstat S_ISFIFO($f[2]) ? 'P' : S_ISSOCK($f[2]) ? 'S' : die ("$filename: unsupported file type\n"); - return bless - [ + return bless [ $filename, # name @f[0,1], # dev,ino $type, # type @@ -184,8 +179,7 @@ our ($slave_mode,$local_slave,$slave_unprivileged, our ($in,$out); # partner communication channel # command channel our $data; # data channel -our -( +our ( %HARDLINK, # ( 'dev.inode' => first-filename-save , ... ) cache for indexer %LOCAL_DEV, # ( 'dev' => path , ... ) non-nfs filesystems for indexer @@ -198,10 +192,8 @@ our $bw_column = 0; sub is_excepted { my ($fn)=@_; - for my $pat (@EXCEPTS) - { - if (fnmatch($pat,$fn,FNM_PATHNAME|FNM_PERIOD)) - { + for my $pat (@EXCEPTS) { + if (fnmatch($pat,$fn,FNM_PATHNAME|FNM_PERIOD)) { return 1; } } @@ -214,8 +206,7 @@ sub cache_local_fs #/dev/sdb on /amd/afk/1 type xfs (rw,noatime) #OneFS on /ifs (efs, NFS exported, local, noatime, noexec) - for (`mount`) - { + for (`mount`) { m"(.+) on (/.*) type (\S+)" || m"(.+) on (/.*) \(([^,)]+),"; my ($fs,$path,$type)=($1,$2,$3); next unless $type && $type =~ /^advfs|ufs|ext\d+|reiserfs|xfs|fuseblk|vfat|efs|tmpfs|btrfs$/; @@ -228,28 +219,19 @@ sub cache_local_fs our ($machine,$SYS_lchown,$SYS_mknod,$lmtime_sub); chomp($machine=`uname -m`); -if ($machine eq 'i686') -{ +if ($machine eq 'i686') { $SYS_lchown=198; # __NR_lchown32 in /usr/include/asm/unistd.h $SYS_mknod=14; # __NR_mknod -} -elsif ($machine eq 'x86_64') -{ +} elsif ($machine eq 'x86_64') { $SYS_lchown=94; # __NR_lchown in /usr/include/asm-x86_64/unistd.h $SYS_mknod=133; # __NR_mknod -} -elsif ($machine eq 'alpha') -{ - +} elsif ($machine eq 'alpha') { $SYS_lchown=208; # SYS_lchown in /usr/include/syscall.h $SYS_mknod=14; # SYS_mknod -} -elsif ($machine eq 'amd64') { +} elsif ($machine eq 'amd64') { $SYS_lchown=254; # SYS_lchown in /usr/include/syscall.h $SYS_mknod=14; # SYS_mknod -} -else -{ +} else { warn "unknown machine type $machine: symlink ownership can't be set.\n"; warn "unknown machine type $machine: named pipes,character and block devices can't be created\n"; } @@ -345,14 +327,12 @@ sub fileop_cp my @f=stat($from) or die "$from: $!\n"; my $in=new IO::File $from,O_RDONLY or die "$from: $!\n"; my $out=new IO::File $to,O_CREAT|O_EXCL|O_WRONLY or die "$to: $!\n"; - if ($IO::File::VERSION >= 1.13) - { + if ($IO::File::VERSION >= 1.13) { $in->binmode; $out->binmode; } my $buf; - while ($in->sysread($buf,10240)) - { + while ($in->sysread($buf,10240)) { $out->syswrite($buf) or die "$out: $!\n"; } close $in; @@ -401,8 +381,7 @@ sub fileop_ln_or_cp my ($from,$to)=@_; $fileop_debug and warn "fileop: ln_or_cp $from $to\n"; $fileop_noop and return; - unless (link $from,$to) - { + unless (link $from,$to) { fileop_cp($from,$to); } } @@ -421,20 +400,16 @@ sub size defined($n) or $n = 1; my @T=(); - for (my $f = 4; $f >= 0; $f--) - { + for (my $f = 4; $f >= 0; $f--) { my $t = int($s/(1024**$f)); push @T, ($t > 0) ? $t : 0; # TB/GB/MB/Kb/B $s -= $t*(1024**$f); } my @L; - for my $x ('TB','GB','MB','kB','B') - { + for my $x ('TB','GB','MB','kB','B') { my $y = shift @T; - if ($y != 0) - { - if (defined($n)) - { + if ($y != 0) { + if (defined($n)) { $n--; last if ($n < 0); } @@ -450,8 +425,7 @@ sub receive_bytes { my ($io,$bufref,$len)=@_; my $index=0; - while($len) - { + while($len) { my $l = $io->sysread($$bufref,$len,$index); $l or return $l; $len-=$l; @@ -493,13 +467,11 @@ sub send_file my $len; my $fh=IO::File->new($filename,O_RDONLY); - unless (defined $fh) - { + unless (defined $fh) { # one reason to get here is that the file was deleted after it has been offered to # and requested by the client. - if ($!==2) # ENOENT - { + if ($!==2) { # ENOENT warn "$filename: file has been removed on master after client requested it. aborting transfer\n"; $len=0; $out->syswrite(pack('n',0),2); @@ -513,27 +485,23 @@ sub send_file my $duration = 0; my $size = ($fh->stat())[7]; - if ($bandwidth && !$quiet) - { + if ($bandwidth && !$quiet) { $duration = Time::HiRes::time(); my $oc = 8 + length($filename); - if ( $oc > $bw_column ) - { + if ( $oc > $bw_column ) { $bw_column = $oc + 1.0; } $bw_column -= 0.02; printf STDERR " %*s ",int($bw_column-$oc)+7,size($size,1); } - while(1) - { + while(1) { $len=$fh->sysread($data_buf,10240,2); defined $len or die "$filename: $!\n"; substr($data_buf,0,2)=pack('n',$len); writebuf($out,$data_buf,$len+2) or die "$filename: $!\n"; $len or last; } - if ($bandwidth && !$quiet) - { + if ($bandwidth && !$quiet) { $duration = Time::HiRes::time() - $duration + 0.00001; # prevent div by zero printf STDERR " in %5.2fs %7s/s",$duration,size($size/$duration,1); } @@ -545,8 +513,7 @@ sub receive_file my $fh; $fh=IO::File->new($filename,O_WRONLY|O_CREAT,$perm); defined $fh or die "$filename: $!\n"; - while(1) - { + while(1) { my $data_buf; my $l; @@ -558,12 +525,9 @@ sub receive_file $expected_size-=$l; } $fh->sync(); - if ($expected_size>0) - { + if ($expected_size>0) { warn "master sent less file data than expected\n"; - } - elsif ($expected_size<0) - { + } elsif ($expected_size<0) { warn "master sent more file data than expected\n"; } } @@ -589,22 +553,19 @@ sub master_wanted_func # s(^\./)(); # remove "./" prefix - if (is_excepted($filename)) - { + if (is_excepted($filename)) { $File::Find::prune=1; return; } my $st=My::FileInfo->lstat($filename); - unless ($st) - { + unless ($st) { warn "$filename : $!\n"; $File::Find::prune=1; return; } - if ( !exists $LOCAL_DEV{$st->dev} && !$allowremotefs && !($st->dev == -1 && $st->type eq 'P')) # osf bug: pipes show -1 as dev - { + if ( !exists $LOCAL_DEV{$st->dev} && !$allowremotefs && !($st->dev == -1 && $st->type eq 'P')) { # osf bug: pipes show -1 as dev warn "master_wanted_func: $filename : remote filesystem\n"; $File::Find::prune=1; return; @@ -617,15 +578,11 @@ sub master_wanted_func my $hardlink='-'; - if ($st->type ne 'D' && $st->nlink>1) - { + if ($st->type ne 'D' && $st->nlink>1) { my $tag=$st->dev.'.'.$st->ino; - if (exists $HARDLINK{$tag}) - { + if (exists $HARDLINK{$tag}) { $hardlink=$HARDLINK{$tag} - } - else - { + } else { $HARDLINK{$tag}=$st->name_escaped } } @@ -633,32 +590,23 @@ sub master_wanted_func my $sum= $cksum && $st->type eq 'F' ? cksum($filename) : '-'; $out->print($st->export_index,$hardlink,$sum); - if ($st->type eq 'F') - { + if ($st->type eq 'F') { my $reply=$in->getline; defined $reply or die "client disconnected\n"; chomp($reply); - if ($reply eq 'SEND') - { - if ($bandwidth && !$quiet) - { + if ($reply eq 'SEND') { + if ($bandwidth && !$quiet) { # note: we have $\ set, so use printf, not print printf STDERR 'sending %s',$filename; send_file($filename); printf STDERR "\n"; - } - else - { + } else { $quiet or warn "sending $filename\n"; send_file($filename); } - } - elsif ($reply eq 'CONTINUE') - { + } elsif ($reply eq 'CONTINUE') { ; - } - else - { + } else { die "unexpected client reply: $reply\n"; } } @@ -693,14 +641,12 @@ sub master cache_local_fs(); - if ($safety) - { + if ($safety) { my $safety_file="$master_path/.PMIRROR_ENABLED"; -e $safety_file or die "safety file $safety_file not found. Terminating\n"; } - if ($lockident) - { + if ($lockident) { use Fcntl (':flock'); my $lockfilename='/var/lock/pmirror.'.$lockident.'.lock'; our $lock_handle=IO::File->new($lockfilename,O_CREAT|O_WRONLY,0777); @@ -708,8 +654,7 @@ sub master flock($lock_handle,LOCK_EX|LOCK_NB) or die (($!==11 || $!==35) ? "mirror $lockident already running\n" : "$lockfilename: $!\n"); } - unless ($allowremotefs) - { + unless ($allowremotefs) { my $st=My::FileInfo->lstat('.'); $st or die "$master_path : $!\n"; exists $LOCAL_DEV{$st->dev} or die "$master_path: remote filesystem\n"; @@ -719,8 +664,7 @@ sub master my $slave_to_master = new IO::Pipe; # from remote slave to us defined (my $pid=fork) or die "$0: $!\n"; - unless ($pid) - { + unless ($pid) { $master_to_slave->reader; $slave_to_master->writer; open STDIN, '<&',$master_to_slave or die "$!"; @@ -741,16 +685,14 @@ sub master $force_status and push @remote_opts,'--force_status'; $bandwidth and push @remote_opts,'--bandwidth'; $allowremotefs and push @remote_opts,'--allowremotefs'; - $cksum and push @remote_opts,'--cksum'; - $nice and push @remote_opts,'--nice'; + $cksum and push @remote_opts,'--cksum'; + $nice and push @remote_opts,'--nice'; ($slave_unprivileged or ($slave_user ne 'root')) and push @remote_opts,'--unprivileged'; my @l; - if ($slave) - { - @l= - ( + if ($slave) { + @l= ( 'ssh', $identity_file ? ('-i',$identity_file) : (), ,'-x', @@ -761,9 +703,7 @@ sub master '/usr/local/bin/pmirror','--slave',@remote_opts,$slave_path # '/project/admin/pdist/pmirror2','--slave',@remote_opts,$slave_path ); - } - else - { + } else { @l=('/usr/local/bin/pmirror','--slave','--local-slave',@remote_opts,$slave_path) # @l=('/project/admin/pdist/pmirror2','--slave','--local-slave',@remote_opts,$slave_path) @@ -782,8 +722,7 @@ sub master local($, , $\)=(' ',"\n"); - if ($slave) - { + if ($slave) { $_=$in->getline; defined $_ or die "client disconnected\n"; /^LISTEN (\d+)$/ or die "protokoll error; expected LISTEN got $_\n"; @@ -793,14 +732,12 @@ sub master ($in,$out)=($s_data,$s_data); } - for (@EXCEPTS) - { + for (@EXCEPTS) { $out->print('!',fn_escape($_)); } local $SIG{__WARN__}=sub { die $_[0] }; - find - ( + find ( { wanted => \&master_wanted_func, no_chdir => 1, # because we work from '.', so File::Find::Fullname ('./laa/bla') is invalid when chdired @@ -821,8 +758,7 @@ sub add_clean_dir { my ($dir)=@_; opendir DIR,$dir or die "$dir: $!\n"; - while (defined (my $file=readdir DIR)) - { + while (defined (my $file=readdir DIR)) { my $path="$dir/$file"; $CLEAN{$path} = 1 unless ($file eq '.' || $file eq '..' || is_excepted($path)); } @@ -834,13 +770,11 @@ sub check_perm my ($st_is,$st_want)=@_; my $path=$st_is->name; $st_is->type eq '-' || $st_is->type eq 'L' and die "internal error"; - if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) - { + if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) { ($quiet || $slave_unprivileged) or warn "chown ".$st_want->uid.':'.$st_want->gid." $path\n"; fileop_chown($st_want->uid,$st_want->gid,$path); } - if ($st_want->perm != $st_is->perm) - { + if ($st_want->perm != $st_is->perm) { $quiet or warn sprintf("chmod %03o %s\n",$st_want->perm,$path); fileop_chmod($st_want->perm,$path); } @@ -861,15 +795,12 @@ sub out_of_the_way $st->type eq '-' and return; - if ($st->type eq 'D') - { + if ($st->type eq 'D') { my $path=$st->name; my $deleteme="$path.deleteme"; fileop_mv($path,$deleteme); push @CLEAN_DIRS,$deleteme; - } - else - { + } else { fileop_rm($st->name); } } @@ -899,14 +830,12 @@ sub slave local($, , $\)=(' ',"\n"); my ($slave_path)=@_; - if ($mkdir_slave && !$fileop_noop) - { + if ($mkdir_slave && !$fileop_noop) { system 'mkdir','-p',$slave_path and exit 1; } chdir $slave_path or die "$slave_path: $!\n"; - unless ($local_slave) - { + unless ($local_slave) { my $s_listen=IO::Socket::INET->new(Listen=>1) or die "$0: $!\n"; my $port=$s_listen->sockport; @@ -926,13 +855,11 @@ sub slave my $crc_missmatch=0; INDEX_RECORD: - while (defined ($_=$in->getline)) - { + while (defined ($_=$in->getline)) { my @F=split ' '; $F[0] eq '%' and last; - if ($F[0] eq '!') - { + if ($F[0] eq '!') { push @EXCEPTS,fn_unescape($F[1]); next; } @@ -940,8 +867,7 @@ INDEX_RECORD: my $st_want=My::FileInfo->import_index(@F); my $filename=$st_want->name; - if (is_excepted($filename)) - { + if (is_excepted($filename)) { $st_want->type eq 'F' and $out->print ('CONTINUE'); next; } @@ -949,86 +875,64 @@ INDEX_RECORD: my $st_is=My::FileInfo->lstat($filename); - if ($st_want->type eq 'D') - { - if ($st_is && $st_is->type eq 'D') - { + if ($st_want->type eq 'D') { + if ($st_is && $st_is->type eq 'D') { check_perm($st_is,$st_want); $delete and add_clean_dir($filename); - } - else - { + } else { $st_is and fileop_rm($filename); make_dir($filename,$st_want->perm,$st_want->uid,$st_want->gid) } push @DIR_MTIME_QUEUE,$filename,$st_want->mtime; - } - else - { + } else { my $hardlink=fn_unescape($F[7]); my $sum=$F[8]; - if ($hardlink ne '-') - { + if ($hardlink ne '-') { my $st_src=My::FileInfo->lstat($hardlink); - unless ($st_src) - { + unless ($st_src) { $fileop_noop or warn "hardlink source $hardlink: $!\n"; $st_want->type eq 'F' and $out->print('CONTINUE'); next; } - if ( !$st_is || $st_is->dev!=$st_src->dev || $st_is->ino != $st_src->ino) - { + if ( !$st_is || $st_is->dev!=$st_src->dev || $st_is->ino != $st_src->ino) { $st_is and out_of_the_way($st_is); $quiet or warn "ln $hardlink $filename\n"; fileop_ln_or_cp($hardlink,$filename) } $st_want->type eq 'F' and $out->print('CONTINUE'); - } - elsif ($st_want->type eq 'F') - { - if (!$st_is || $st_is->type ne 'F' || $st_is->size != $st_want->size || $st_is->mtime != $st_want->mtime) - { - unless ($fileop_noop) - { + } elsif ($st_want->type eq 'F') { + if (!$st_is || $st_is->type ne 'F' || $st_is->size != $st_want->size || $st_is->mtime != $st_want->mtime) { + unless ($fileop_noop) { my $tmpfile=tmpfilename($filename); my $tmp_perm=$slave_unprivileged ? $st_want->perm : 0; - if ($slave_unprivileged && -e $tmpfile) - { + if ($slave_unprivileged && -e $tmpfile) { unlink $tmpfile or die "$tmpfile: $!\n"; } - if ($st_want->size) - { + if ($st_want->size) { $out->print('SEND'); $fileop_debug and warn "fileop: receiving $tmpfile\n"; receive_file($tmpfile,$st_want->size,$tmp_perm); - } - else - { + } else { $out->print('CONTINUE'); $quiet or warn "creating empty $filename\n"; $fileop_debug and warn "fileop: creating $tmpfile\n"; IO::File->new($tmpfile,O_WRONLY|O_CREAT,$tmp_perm) or die "$tmpfile: $!\n"; } - unless ($slave_unprivileged) - { + unless ($slave_unprivileged) { fileop_chown($st_want->uid,$st_want->gid,$tmpfile); fileop_chmod($st_want->perm,$tmpfile); } $st_is and $st_is->type eq 'D' and out_of_the_way($st_is); fileop_mv($tmpfile,$filename); utime($st_want->mtime,$st_want->mtime,$filename); - } - else - { + } else { $quiet or warn "mirror $filename\n"; $out->print('CONTINUE'); } - } - else - { + } else { unless ($reduce) { if ($cksum) { my $is_sum=cksum($filename); @@ -1041,21 +945,15 @@ INDEX_RECORD: } $out->print('CONTINUE'); } - } - elsif ($st_want->type eq 'L') - { - if (!$st_is || $st_is->type ne 'L' || $st_is->target ne $st_want->target) - { + } elsif ($st_want->type eq 'L') { + if (!$st_is || $st_is->type ne 'L' || $st_is->target ne $st_want->target) { $st_is and out_of_the_way($st_is); $quiet or warn "ln -s ".$st_want->target." $filename\n"; fileop_symlink($st_want->target,$filename); fileop_lchown($st_want->uid,$st_want->gid,$filename); fileop_lmtime($st_want->mtime,$filename); - } - else - { - if (!$slave_unprivileged && ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid)) - { + } else { + if (!$slave_unprivileged && ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid)) { $quiet or warn "lchown ".$st_want->uid.':'.$st_want->gid." $filename\n"; fileop_lchown($st_want->uid,$st_want->gid,$filename); } @@ -1064,43 +962,29 @@ INDEX_RECORD: fileop_lmtime($st_want->mtime,$filename); } } - } - elsif ($st_want->type eq 'P') - { - if (!$st_is || $st_is->type ne 'P') - { + } elsif ($st_want->type eq 'P') { + if (!$st_is || $st_is->type ne 'P') { $st_is and out_of_the_way($st_is); $quiet or warn "mknod $filename P\n"; fileop_mknod($filename,'P'); fileop_chown($st_want->uid,$st_want->gid,$filename); fileop_chmod($st_want->perm,$filename); - } - else - { + } else { check_perm($st_is,$st_want); } - } - elsif ($st_want->type eq 'S') - { + } elsif ($st_want->type eq 'S') { warn "$filename: is a socket (ignored)\n"; - } - elsif ($st_want->type eq 'C' || $st_want->type eq 'B') - { - if (!$st_is || $st_is->type ne $st_want->type || $st_is->rdev != $st_want->rdev) - { + } elsif ($st_want->type eq 'C' || $st_want->type eq 'B') { + if (!$st_is || $st_is->type ne $st_want->type || $st_is->rdev != $st_want->rdev) { $st_is and out_of_the_way($st_is); $quiet or warn "mknod $filename ",$st_want->type,"\n"; fileop_mknod($filename,$st_want->type,$st_want->rdev); fileop_chown($st_want->uid,$st_want->gid,$filename); fileop_chmod($st_want->perm,$filename); - } - else - { + } else { check_perm($st_is,$st_want); } - } - else - { + } else { warn "$filename: type ".$st_want->type." not yet implemented\n"; } } @@ -1108,32 +992,24 @@ INDEX_RECORD: defined $_ or die "unexpected EOF from master\n"; # emergency exit $reduce and $fileop_noop=$reduce_saved_fileop_noop; - if ($delete) - { + if ($delete) { $debug and warn "cleanup\n"; - for my $path (keys %CLEAN) - { + for my $path (keys %CLEAN) { lstat $path or die "$path: $!\n"; - if (-e _) - { - if (-d _) - { + if (-e _) { + if (-d _) { $quiet or warn "rm -r $path\n"; fileop_rmdir_recurse($path); - } - else - { + } else { $quiet or warn "rm $path\n"; fileop_rm($path); } } } - for my $path (@CLEAN_DIRS) - { - if (-e $path) - { + for my $path (@CLEAN_DIRS) { + if (-e $path) { $quiet or warn "rm -r $path\n"; fileop_rmdir_recurse($path); } @@ -1141,21 +1017,16 @@ INDEX_RECORD: } $reduce and exit; - for (my $i=0;$i<@DIR_MTIME_QUEUE;$i+=2) - { + for (my $i=0;$i<@DIR_MTIME_QUEUE;$i+=2) { my ($fn,$mtime)=($DIR_MTIME_QUEUE[$i],$DIR_MTIME_QUEUE[$i+1]); - if (my @f=lstat $fn) - { + if (my @f=lstat $fn) { S_ISDIR($f[2]) or next; # no longer a directory $f[9]==$mtime and next; # mtime is okay $quiet or warn "fix directory mtime of $fn ",$f[9],' -> ',$mtime,"\n"; - unless ($fileop_noop) - { + unless ($fileop_noop) { utime($mtime,$mtime,$fn) or warn "$fn: $!\n"; } - } - else - { + } else { warn "$fn: $!\n" unless $fileop_noop; } } @@ -1164,14 +1035,12 @@ INDEX_RECORD: die "completed with $crc_missmatch CRC errors\n"; } - if ( !$fileop_noop && ($force_status || -e '.PMIRROR_STATUS')) - { + if ( !$fileop_noop && ($force_status || -e '.PMIRROR_STATUS')) { my $t=time; open L,'>','.PMIRROR_STATUS' or die ".PMIRROR_STATUS: $!\n"; print L 'OK',$t,scalar(localtime($t)); close L; } - } #-------------------------------------------- @@ -1203,8 +1072,7 @@ usage: $0 [options] path [node:]path __EOF__ -use constant OPTIONS => -( +use constant OPTIONS => ( 'slave' => \$slave_mode, 'local-slave' => \$local_slave, 'unprivileged' => \$slave_unprivileged, @@ -1229,9 +1097,7 @@ use constant OPTIONS => 'nice' => \$nice, ); -if ($ENV{SSH_ORIGINAL_COMMAND}) -{ - +if ($ENV{SSH_ORIGINAL_COMMAND}) { ($_,@ARGV)=split ' ',$ENV{SSH_ORIGINAL_COMMAND}; } @@ -1241,14 +1107,11 @@ if ($nice) { system 'ionice','-c','idle','-p',$$; } -if ($slave_mode) -{ +if ($slave_mode) { @ARGV==1 or die USAGE; my ($slave_path)=@ARGV; slave($slave_path); -} -else -{ +} else { @ARGV==2 or die USAGE; my ($master_path,$target)=@ARGV; @@ -1264,16 +1127,12 @@ else my ($slave,$slave_path); my $slave_user='root'; - if ($target=~/^([^:]+):(.+)$/) # system:/path - { + if ($target=~/^([^:]+):(.+)$/) { # system:/path ($slave,$slave_path)=($1,$2); - if ($slave=~/^([^\@]+)\@(.+)$/) # user@system:/path - { + if ($slave=~/^([^\@]+)\@(.+)$/) { # user@system:/path ($slave_user, $slave) = ($1, $2); } - } - else # /path - { + } else { # /path ($slave,$slave_path)=('',$target); $>==0 or $slave_user='whatever'; # if we are not root, the local slave will also no be root }