mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 22:17:54 +00:00
Added warning if --trc/--transfer/--return without -S.
Added warning if --transfer and file unreadable. Unittest of transfering of filename with \n passes.
This commit is contained in:
parent
55fa0189fb
commit
ca4e58fbaf
46
src/parallel
46
src/parallel
|
@ -495,6 +495,8 @@ permits. If {} is not used the arguments will be appended to the line.
|
||||||
If {} is used multiple times each {} will be replaced with all the
|
If {} is used multiple times each {} will be replaced with all the
|
||||||
arguments.
|
arguments.
|
||||||
|
|
||||||
|
Support for B<-m> with B<--sshlogin> is limited and may fail.
|
||||||
|
|
||||||
|
|
||||||
=item B<-X>
|
=item B<-X>
|
||||||
|
|
||||||
|
@ -503,6 +505,8 @@ of a word (like I<pic{}.jpg>) then the whole word will be
|
||||||
repeated. Normally B<-X> will do the right thing, whereas B<-m> can
|
repeated. Normally B<-X> will do the right thing, whereas B<-m> can
|
||||||
give surprising results if {} is used as part of a word.
|
give surprising results if {} is used as part of a word.
|
||||||
|
|
||||||
|
Support for B<-X> with B<--sshlogin> is limited and may fail.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 EXAMPLE: Working as xargs -n1. Argument appending
|
=head1 EXAMPLE: Working as xargs -n1. Argument appending
|
||||||
|
@ -1427,6 +1431,21 @@ sub shell_quote {
|
||||||
return wantarray ? @strings : "@strings";
|
return wantarray ? @strings : "@strings";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub shell_unquote {
|
||||||
|
# Unquote strings from shell_quote
|
||||||
|
my (@strings) = (@_);
|
||||||
|
my $arg;
|
||||||
|
for $arg (@strings) {
|
||||||
|
$arg =~ s/'\n'/\n/g; # filenames with '\n' is quoted using \'
|
||||||
|
$arg =~ s/\\([\002-\011\013-\032])/$1/g;
|
||||||
|
$arg =~ s/\\([\#\?\`\(\)\*\>\<\~\|\; \"\!\$\&\'])/$1/g;
|
||||||
|
$arg =~ s/\\\\/\\/g;
|
||||||
|
}
|
||||||
|
return wantarray ? @strings : "@strings";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Replace foo{}bar or foo{.}bar
|
# Replace foo{}bar or foo{.}bar
|
||||||
sub context_replace {
|
sub context_replace {
|
||||||
my ($job_line,$quoted,$no_ext) = (@_);
|
my ($job_line,$quoted,$no_ext) = (@_);
|
||||||
|
@ -1837,7 +1856,11 @@ sub next_command_line_with_sshlogin {
|
||||||
# --transfer
|
# --transfer
|
||||||
# Abs path: rsync -rlDzR /home/tange/dir/subdir/file.gz server:/
|
# Abs path: rsync -rlDzR /home/tange/dir/subdir/file.gz server:/
|
||||||
# Rel path: rsync -rlDzR ./subdir/file.gz server:./
|
# Rel path: rsync -rlDzR ./subdir/file.gz server:./
|
||||||
$pre = "rsync $rsync_opt $file $serverlogin:$rsync_destdir ;";
|
if(-r shell_unquote($file)) {
|
||||||
|
$pre = "rsync $rsync_opt $file $serverlogin:$rsync_destdir ;";
|
||||||
|
} else {
|
||||||
|
print STDERR "Warning: $file is not readable and will not be transferred\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for my $ret_file (@Global::ret_files) {
|
for my $ret_file (@Global::ret_files) {
|
||||||
my $remove = $::opt_cleanup ? "--remove-source-files" : "";
|
my $remove = $::opt_cleanup ? "--remove-source-files" : "";
|
||||||
|
@ -2106,6 +2129,22 @@ sub parse_sshlogin {
|
||||||
$Global::host{$sshlogin}{'maxlength'} = max_length_of_command_line();
|
$Global::host{$sshlogin}{'maxlength'} = max_length_of_command_line();
|
||||||
}
|
}
|
||||||
debug("sshlogin: ", my_dump(%Global::host));
|
debug("sshlogin: ", my_dump(%Global::host));
|
||||||
|
if($::opt_transfer or @::opt_return or $::opt_cleanup) {
|
||||||
|
my @remote_hosts = grep !/^:$/, keys %Global::host;
|
||||||
|
debug("Remote hosts: ",@remote_hosts);
|
||||||
|
if(not @remote_hosts) {
|
||||||
|
# There are no remote hosts
|
||||||
|
if(defined @::opt_trc) {
|
||||||
|
print STDERR "Warning: --trc ignored as there are no remote --sshlogin\n";
|
||||||
|
} elsif (defined $::opt_transfer) {
|
||||||
|
print STDERR "Warning: --transfer ignored as there are no remote --sshlogin\n";
|
||||||
|
} elsif (defined @::opt_return) {
|
||||||
|
print STDERR "Warning: --return ignored as there are no remote --sshlogin\n";
|
||||||
|
} elsif (defined $::opt_cleanup) {
|
||||||
|
print STDERR "Warning: --cleanup ignored as there are no remote --sshlogin\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub sshcommand_of_sshlogin {
|
sub sshcommand_of_sshlogin {
|
||||||
|
@ -2315,9 +2354,7 @@ $main::opt_E = $main::opt_r = $Global::xargs = $Global::keeporder = 0;
|
||||||
# TODO max_line_length on remote
|
# TODO max_line_length on remote
|
||||||
# TODO compute how many can be transferred within max_line_length
|
# TODO compute how many can be transferred within max_line_length
|
||||||
# TODO Unittest with filename that is long and requires a lot of quoting. Will there be to many
|
# TODO Unittest with filename that is long and requires a lot of quoting. Will there be to many
|
||||||
# TODO Unittest --trc/--transfer/--return without -S should warn
|
|
||||||
# TODO --max-number-of-jobs print the system limited number of jobs
|
# TODO --max-number-of-jobs print the system limited number of jobs
|
||||||
# TODO Unittest with dir containing . and file with noextension and {.}
|
|
||||||
|
|
||||||
#=item B<--sshlogin> I<[ncpu/]sshlogin[,[ncpu/]sshlogin[,...]]> (beta testing)
|
#=item B<--sshlogin> I<[ncpu/]sshlogin[,[ncpu/]sshlogin[,...]]> (beta testing)
|
||||||
# Skilletegn:
|
# Skilletegn:
|
||||||
|
@ -2329,5 +2366,4 @@ $main::opt_E = $main::opt_r = $Global::xargs = $Global::keeporder = 0;
|
||||||
# %/=:_^
|
# %/=:_^
|
||||||
|
|
||||||
# Check transfer of newline file to sshlogin with own ssh and more than 9 simultaneously
|
# Check transfer of newline file to sshlogin with own ssh and more than 9 simultaneously
|
||||||
# TODO Unittest seq 1 11 | parallel --trc -j10000% -S "myssh -l tange nlv.pi.dk" echo
|
# TODO Unittest myssh: parallel --trc -j10000% -S "myssh -l tange nlv.pi.dk" echo
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
SHFILE=/tmp/unittest-parallel.sh
|
||||||
|
|
||||||
ls -t tests-to-run/test*.sh \
|
ls -t tests-to-run/test*.sh \
|
||||||
| perl -pe 's:(.*/(.*)).sh:sh $1.sh > actual-results/$2; diff -Naur wanted-results/$2 actual-results/$2:' \
|
| perl -pe 's:(.*/(.*)).sh:sh $1.sh > actual-results/$2; diff -Naur wanted-results/$2 actual-results/$2:' \
|
||||||
| sh -x
|
>$SHFILE
|
||||||
|
|
||||||
|
sh -x $SHFILE
|
||||||
|
rm $SHFILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
### Test weird regexp chars
|
### Test weird regexp chars
|
||||||
a1b1^c1[.}c a2b2^c2[.}c a3b3^c3[.}c a4b4^c4[.}c a5b5^c5[.}c a6b6^c6[.}c
|
a1b1^c1[.}c a2b2^c2[.}c a3b3^c3[.}c a4b4^c4[.}c a5b5^c5[.}c a6b6^c6[.}c
|
||||||
### Test {.} and {}
|
### Test {.} and {}
|
||||||
|
### Test {.} with files that have no . but dir does
|
||||||
|
/tmp/test-of-{.}-parallel/subdir/file
|
||||||
|
/tmp/test-of-{.}-parallel/subdir/file{.}
|
||||||
ls 1-col.diff|wc;echo 1-col.diff
|
ls 1-col.diff|wc;echo 1-col.diff
|
||||||
1 1 11
|
1 1 11
|
||||||
1-col.diff
|
1-col.diff
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
### Check warning if --transfer but file not found
|
||||||
|
Warning: /tmp/noexistant/file is not readable and will not be transferred
|
||||||
|
/tmp/noexistant/file
|
||||||
|
### Check warning if --transfer but not --sshlogin
|
||||||
|
Warning: --transfer ignored as there are no remote --sshlogin
|
||||||
|
|
||||||
|
### Check warning if --return but not --sshlogin
|
||||||
|
Warning: --return ignored as there are no remote --sshlogin
|
||||||
|
|
||||||
|
### Check warning if --cleanup but not --sshlogin
|
||||||
|
Warning: --cleanup ignored as there are no remote --sshlogin
|
||||||
|
|
||||||
### Test --sshlogin -S --sshloginfile
|
### Test --sshlogin -S --sshloginfile
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
|
|
|
@ -13,6 +13,14 @@ cd tmp
|
||||||
echo '### Test {.} and {}'
|
echo '### Test {.} and {}'
|
||||||
find . -name '*.jpg' | $PAR -j +0 convert -geometry 120 {} {.}_thumb.jpg
|
find . -name '*.jpg' | $PAR -j +0 convert -geometry 120 {} {.}_thumb.jpg
|
||||||
|
|
||||||
|
echo '### Test {.} with files that have no . but dir does'
|
||||||
|
mkdir -p /tmp/test-of-{.}-parallel/subdir
|
||||||
|
touch /tmp/test-of-{.}-parallel/subdir/file
|
||||||
|
touch /tmp/test-of-{.}-parallel/subdir/file{.}.funkyextension}}
|
||||||
|
find /tmp/test-of-{.}-parallel -type f | $PAR echo {.}
|
||||||
|
rm -rf /tmp/test-of-{.}-parallel/subdir
|
||||||
|
|
||||||
|
|
||||||
find -type f | $PAR -k diff {} a/foo ">"{.}.diff
|
find -type f | $PAR -k diff {} a/foo ">"{.}.diff
|
||||||
ls | $PAR -kvg "ls {}|wc;echo {}"
|
ls | $PAR -kvg "ls {}|wc;echo {}"
|
||||||
ls | $PAR -kj500 'sleep 1; ls {} | perl -ne "END{print $..\" {}\n\"}"'
|
ls | $PAR -kj500 'sleep 1; ls {} | perl -ne "END{print $..\" {}\n\"}"'
|
||||||
|
|
|
@ -5,6 +5,18 @@ PAR=parallel
|
||||||
SERVER1=parallel-server1
|
SERVER1=parallel-server1
|
||||||
SERVER2=parallel-server2
|
SERVER2=parallel-server2
|
||||||
|
|
||||||
|
echo '### Check warning if --transfer but file not found'
|
||||||
|
echo /tmp/noexistant/file | stdout $PAR -k -S $SERVER1 --transfer echo
|
||||||
|
|
||||||
|
echo '### Check warning if --transfer but not --sshlogin'
|
||||||
|
echo | stdout $PAR -k --transfer echo
|
||||||
|
|
||||||
|
echo '### Check warning if --return but not --sshlogin'
|
||||||
|
echo | stdout $PAR -k --return {} echo
|
||||||
|
|
||||||
|
echo '### Check warning if --cleanup but not --sshlogin'
|
||||||
|
echo | stdout $PAR -k --cleanup echo
|
||||||
|
|
||||||
echo '### Test --sshlogin -S --sshloginfile'
|
echo '### Test --sshlogin -S --sshloginfile'
|
||||||
echo localhost >/tmp/parallel-sshlogin
|
echo localhost >/tmp/parallel-sshlogin
|
||||||
seq 1 3 | $PAR -k --sshlogin 8/$SERVER1 -S "7/ssh -l parallel $SERVER2",: --sshloginfile /tmp/parallel-sshlogin echo
|
seq 1 3 | $PAR -k --sshlogin 8/$SERVER1 -S "7/ssh -l parallel $SERVER2",: --sshloginfile /tmp/parallel-sshlogin echo
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
### Test weird regexp chars
|
### Test weird regexp chars
|
||||||
a1b1^c1[.}c a2b2^c2[.}c a3b3^c3[.}c a4b4^c4[.}c a5b5^c5[.}c a6b6^c6[.}c
|
a1b1^c1[.}c a2b2^c2[.}c a3b3^c3[.}c a4b4^c4[.}c a5b5^c5[.}c a6b6^c6[.}c
|
||||||
### Test {.} and {}
|
### Test {.} and {}
|
||||||
|
### Test {.} with files that have no . but dir does
|
||||||
|
/tmp/test-of-{.}-parallel/subdir/file
|
||||||
|
/tmp/test-of-{.}-parallel/subdir/file{.}
|
||||||
ls 1-col.diff|wc;echo 1-col.diff
|
ls 1-col.diff|wc;echo 1-col.diff
|
||||||
1 1 11
|
1 1 11
|
||||||
1-col.diff
|
1-col.diff
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
### Check warning if --transfer but file not found
|
||||||
|
Warning: /tmp/noexistant/file is not readable and will not be transferred
|
||||||
|
/tmp/noexistant/file
|
||||||
|
### Check warning if --transfer but not --sshlogin
|
||||||
|
Warning: --transfer ignored as there are no remote --sshlogin
|
||||||
|
|
||||||
|
### Check warning if --return but not --sshlogin
|
||||||
|
Warning: --return ignored as there are no remote --sshlogin
|
||||||
|
|
||||||
|
### Check warning if --cleanup but not --sshlogin
|
||||||
|
Warning: --cleanup ignored as there are no remote --sshlogin
|
||||||
|
|
||||||
### Test --sshlogin -S --sshloginfile
|
### Test --sshlogin -S --sshloginfile
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
|
|
Loading…
Reference in a new issue