diff --git a/src/parallel b/src/parallel index 9ea69033..b6306cbd 100755 --- a/src/parallel +++ b/src/parallel @@ -115,7 +115,10 @@ sub halt() { } wait_and_exit($Global::halt_exitstatus); } else { - wait_and_exit(min(undef_as_zero($Global::exitstatus),101)); + if(not defined $Global::halt_exitstatus) { + wait_and_exit(min(undef_as_zero($Global::exitstatus),101)); + } + wait_and_exit($Global::halt_exitstatus); } } @@ -1696,6 +1699,7 @@ sub options_hash() { "semaphoretimeout|st=s" => \$opt::semaphoretimeout, "semaphorename|id=s" => \$opt::semaphorename, "fg" => \$opt::fg, + "fg-exit" => \$opt::fg_exit, "bg" => \$opt::bg, "wait" => \$opt::wait, # Shebang #!/usr/bin/parallel --shebang @@ -11101,6 +11105,14 @@ sub set_exitsignal($$) { $limit = $Global::total_completed; } if(not defined $limit) { + if($opt::fg and $opt::fg_exit and not defined $Global::halt_exitstatus) { + # --fg-exit + # Emulate Bash's +128 if there is a signal + $Global::halt_exitstatus = + ($job->exitstatus() + or + $job->exitsignal() ? $job->exitsignal() + 129 : 0); + } return "" } # --halt # => 1..100 (number of jobs failed, 101 means > 100) diff --git a/src/parallel.pod b/src/parallel.pod index 2e2c6424..0bac31c8 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -908,7 +908,18 @@ foreground (opposite B<--bg>), and wait for completion of the command before exiting. -See also: B<--bg> B +See also: B<--fg-exit> B<--bg> B + + +=item B<--fg-exit> + +Return exit code of command. + +Along with B<--fg> the exit value of GNU B will be that of +the command being run. + + +See also: B<--fg-exit> B<--bg> B =item B<--fifo>