parallel: --pipe --cat tested with csh.

This commit is contained in:
Ole Tange 2015-01-18 00:20:38 +01:00
parent ca03efde42
commit b784f4eca6
5 changed files with 72 additions and 18 deletions

View file

@ -5710,6 +5710,32 @@ sub total_failed {
return $total_failures; return $total_failures;
} }
{
my $script;
sub postpone_exit_and_cleanup {
# Command to remove files and dirs (given as args) without
# affecting the exit value in $?/$status.
if(not $script) {
$script = "perl -e '".
::spacefree(0,q{
$bash=shift;
$csh=shift;
for(@ARGV){
unlink;
rmdir;
}
if($bash=~s/h//) {
exit $bash;
}
exit $csh;
}).
"' ".'"$?h" "$status" ';
}
return $script
}
}
sub wrapped { sub wrapped {
# Wrap command with: # Wrap command with:
# * --shellquote # * --shellquote
@ -5754,22 +5780,23 @@ sub wrapped {
} }
if($opt::cat) { if($opt::cat) {
# Prepend 'cat > {};' # Prepend 'cat > {};'
# Append '_EXIT=$?;(rm {};exit $_EXIT)' # Append 'unlink {} without affecting $?'
$command = $command =
$self->{'commandline'}->replace_placeholders(["cat > \257<\257>; "], 0, 0). $self->{'commandline'}->replace_placeholders(["cat > \257<\257>; "], 0, 0).
$command. $command.";". postpone_exit_and_cleanup().
$self->{'commandline'}->replace_placeholders( $self->{'commandline'}->replace_placeholders(["\257<\257>"], 0, 0);
["; _EXIT=\$?; rm \257<\257>; exit \$_EXIT"], 0, 0);
} elsif($opt::fifo) { } elsif($opt::fifo) {
# Prepend 'mkfifo {}; (' # Prepend 'mkfifo {}; ('
# Append ') & _PID=$!; cat > {}; wait $_PID; _EXIT=$?;(rm {};exit $_EXIT)' # Append ') & _PID=$!; cat > {}; wait $_PID; '
# (This makes it fail in csh, but give the correct exit code in bash)
# Append 'unlink {} without affecting $?'
$command = $command =
$self->{'commandline'}->replace_placeholders(["mkfifo \257<\257>; ("], 0, 0). $self->{'commandline'}->replace_placeholders(["mkfifo \257<\257>;\n ("], 0, 0).
$command. $command.";".
$self->{'commandline'}->replace_placeholders([") & _PID=\$!; cat > \257<\257>; ", $self->{'commandline'}->replace_placeholders([") & _PID=\$!; cat > \257<\257>; ",
"wait \$_PID; _EXIT=\$?; ", "wait \$_PID; "]).
"rm \257<\257>; exit \$_EXIT"], postpone_exit_and_cleanup().
0,0); $self->{'commandline'}->replace_placeholders(["\257<\257>"], 0, 0);
} }
# Wrap with ssh + tranferring of files # Wrap with ssh + tranferring of files
$command = $self->sshlogin_wrap($command); $command = $self->sshlogin_wrap($command);
@ -5872,7 +5899,7 @@ sub hex_zip_eval {
} }
wait; wait;
eval $eval; eval $eval;
}); });
::debug("hex",$script,"\n"); ::debug("hex",$script,"\n");
return $script; return $script;
} }
@ -8551,4 +8578,4 @@ sub mkdir_or_die {
# Keep perl -w happy # Keep perl -w happy
$opt::ctrlc = $opt::x = $Semaphore::timeout = $Semaphore::wait = $opt::ctrlc = $opt::x = $Semaphore::timeout = $Semaphore::wait =
$Job::file_descriptor_warning_printed = 0; $opt::ignored_option = $Job::file_descriptor_warning_printed = 0;

View file

@ -44,4 +44,14 @@ echo '### bug #42999: --pipepart with remote does not work'
parallel --sshdelay 0.2 --pipepart --block 31 -a /tmp/bug42999 -k --fifo -S parallel@lo wc | perl -pe s:/tmp/.........pip:/tmp/XXXX: ; parallel --sshdelay 0.2 --pipepart --block 31 -a /tmp/bug42999 -k --fifo -S parallel@lo wc | perl -pe s:/tmp/.........pip:/tmp/XXXX: ;
parallel --sshdelay 0.1 --pipepart --block 31 -a /tmp/bug42999 -k --cat -S parallel@lo wc | perl -pe s:/tmp/.........pip:/tmp/XXXX: ; parallel --sshdelay 0.1 --pipepart --block 31 -a /tmp/bug42999 -k --cat -S parallel@lo wc | perl -pe s:/tmp/.........pip:/tmp/XXXX: ;
echo '### --cat gives incorrect exit value in csh'
echo false | parallel --pipe --cat -Scsh@lo 'cat {}; false' ; echo $?;
echo false | parallel --pipe --cat -Stcsh@lo 'cat {}; false' ; echo $?;
echo true | parallel --pipe --cat -Scsh@lo 'cat {}; true' ; echo $?;
echo true | parallel --pipe --cat -Stcsh@lo 'cat {}; true' ; echo $?;
echo '### --cat and --fifo exit value in bash'
echo true | parallel --pipe --fifo -Slo 'cat {}; true' ; echo $?;
echo false | parallel --pipe --fifo -Slo 'cat {}; false' ; echo $?;
EOF EOF

View file

@ -72,3 +72,20 @@ echo '### bug #42999: --pipepart with remote does not work'
11 11 33 /tmp/XXXX 11 11 33 /tmp/XXXX
11 11 33 /tmp/XXXX 11 11 33 /tmp/XXXX
10 9 29 /tmp/XXXX 10 9 29 /tmp/XXXX
echo '### --cat gives incorrect exit value in csh'
### --cat gives incorrect exit value in csh
echo false | parallel --pipe --cat -Scsh@lo 'cat {}; false' ; echo $?; echo false | parallel --pipe --cat -Stcsh@lo 'cat {}; false' ; echo $?; echo true | parallel --pipe --cat -Scsh@lo 'cat {}; true' ; echo $?; echo true | parallel --pipe --cat -Stcsh@lo 'cat {}; true' ; echo $?; echo '### --cat and --fifo exit value in bash'
false
1
false
1
true
0
true
0
### --cat and --fifo exit value in bash
echo true | parallel --pipe --fifo -Slo 'cat {}; true' ; echo $?; echo false | parallel --pipe --fifo -Slo 'cat {}; false' ; echo $?;
true
0
false
1

View file

@ -8,7 +8,7 @@ When using programs that use GNU Parallel to process data for publication please
This helps funding further development; and it won't cost you a cent. This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing. If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'. To silence this citation notice run 'parallel --bibtex' once or use '--will-cite'.
cat - cat -
via first cat via first cat
@ -24,7 +24,7 @@ When using programs that use GNU Parallel to process data for publication please
This helps funding further development; and it won't cost you a cent. This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing. If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'. To silence this citation notice run 'parallel --bibtex' once or use '--will-cite'.
echo a echo a
a a

View file

@ -9,7 +9,7 @@ When using programs that use GNU Parallel to process data for publication please
This helps funding further development; and it won't cost you a cent. This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing. If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'. To silence this citation notice run 'parallel --bibtex' once or use '--will-cite'.
sleep 0.1; echo opt-p 1 ?...y sleep 0.1; echo opt-p 1 ?...y
sleep 0.1; echo opt-p 2 ?...n sleep 0.1; echo opt-p 2 ?...n
@ -25,7 +25,7 @@ When using programs that use GNU Parallel to process data for publication please
This helps funding further development; and it won't cost you a cent. This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing. If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'. To silence this citation notice run 'parallel --bibtex' once or use '--will-cite'.
sleep 0.1; echo opt--interactive 1 ?...y sleep 0.1; echo opt--interactive 1 ?...y
sleep 0.1; echo opt--interactive 2 ?...n sleep 0.1; echo opt--interactive 2 ?...n
@ -267,7 +267,7 @@ When using programs that use GNU Parallel to process data for publication please
This helps funding further development; and it won't cost you a cent. This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing. If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'. To silence this citation notice run 'parallel --bibtex' once or use '--will-cite'.
3 3
1 1
@ -287,7 +287,7 @@ When using programs that use GNU Parallel to process data for publication please
This helps funding further development; and it won't cost you a cent. This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing. If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'. To silence this citation notice run 'parallel --bibtex' once or use '--will-cite'.
1 1
3 3