mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-26 06:37:56 +00:00
parallel: --pipe --cat tested with csh.
This commit is contained in:
parent
ca03efde42
commit
b784f4eca6
51
src/parallel
51
src/parallel
|
@ -5710,6 +5710,32 @@ sub total_failed {
|
|||
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 {
|
||||
# Wrap command with:
|
||||
# * --shellquote
|
||||
|
@ -5754,22 +5780,23 @@ sub wrapped {
|
|||
}
|
||||
if($opt::cat) {
|
||||
# Prepend 'cat > {};'
|
||||
# Append '_EXIT=$?;(rm {};exit $_EXIT)'
|
||||
# Append 'unlink {} without affecting $?'
|
||||
$command =
|
||||
$self->{'commandline'}->replace_placeholders(["cat > \257<\257>; "], 0, 0).
|
||||
$command.
|
||||
$self->{'commandline'}->replace_placeholders(
|
||||
["; _EXIT=\$?; rm \257<\257>; exit \$_EXIT"], 0, 0);
|
||||
$command.";". postpone_exit_and_cleanup().
|
||||
$self->{'commandline'}->replace_placeholders(["\257<\257>"], 0, 0);
|
||||
} elsif($opt::fifo) {
|
||||
# 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 =
|
||||
$self->{'commandline'}->replace_placeholders(["mkfifo \257<\257>; ("], 0, 0).
|
||||
$command.
|
||||
$self->{'commandline'}->replace_placeholders(["mkfifo \257<\257>;\n ("], 0, 0).
|
||||
$command.";".
|
||||
$self->{'commandline'}->replace_placeholders([") & _PID=\$!; cat > \257<\257>; ",
|
||||
"wait \$_PID; _EXIT=\$?; ",
|
||||
"rm \257<\257>; exit \$_EXIT"],
|
||||
0,0);
|
||||
"wait \$_PID; "]).
|
||||
postpone_exit_and_cleanup().
|
||||
$self->{'commandline'}->replace_placeholders(["\257<\257>"], 0, 0);
|
||||
}
|
||||
# Wrap with ssh + tranferring of files
|
||||
$command = $self->sshlogin_wrap($command);
|
||||
|
@ -5872,7 +5899,7 @@ sub hex_zip_eval {
|
|||
}
|
||||
wait;
|
||||
eval $eval;
|
||||
});
|
||||
});
|
||||
::debug("hex",$script,"\n");
|
||||
return $script;
|
||||
}
|
||||
|
@ -8551,4 +8578,4 @@ sub mkdir_or_die {
|
|||
|
||||
# Keep perl -w happy
|
||||
$opt::ctrlc = $opt::x = $Semaphore::timeout = $Semaphore::wait =
|
||||
$Job::file_descriptor_warning_printed = 0;
|
||||
$opt::ignored_option = $Job::file_descriptor_warning_printed = 0;
|
||||
|
|
|
@ -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.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
|
||||
|
|
|
@ -72,3 +72,20 @@ echo '### bug #42999: --pipepart with remote does not work'
|
|||
11 11 33 /tmp/XXXX
|
||||
11 11 33 /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
|
||||
|
|
|
@ -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.
|
||||
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 -
|
||||
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.
|
||||
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
|
||||
a
|
||||
|
|
|
@ -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.
|
||||
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 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.
|
||||
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 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.
|
||||
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
|
||||
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.
|
||||
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
|
||||
3
|
||||
|
|
Loading…
Reference in a new issue