Skip to main content
deleted 7 characters in body
Source Link
Erik Aronesty
  • 13k
  • 6
  • 75
  • 48

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving, or modifying inner loops of scripts. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do wait[ -n z "$(jobs)" ] && break  err="$?"  wait -n  [ "$err" == "127" ] && breakerr="$?" [ "$err" != "0" ] && ecode="$err" done return $ecode } 

EDIT: Fixed the bug where this could be fooled by a script that ran a command that didn't exist.

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving, or modifying inner loops of scripts. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do wait -n  err="$?"  [ "$err" == "127" ] && break [ "$err" != "0" ] && ecode="$err" done return $ecode } 

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving, or modifying inner loops of scripts. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do [ -z "$(jobs)" ] && break  wait -n  err="$?" [ "$err" != "0" ] && ecode="$err" done return $ecode } 

EDIT: Fixed the bug where this could be fooled by a script that ran a command that didn't exist.

added 37 characters in body
Source Link
Erik Aronesty
  • 13k
  • 6
  • 75
  • 48

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving, or modifying inner loops of scripts. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do wait -n err="$?" [ "$err" == "127" ] && break [ "$err" != "0" ] && ecode="$err" done return $ecode } 

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do wait -n err="$?" [ "$err" == "127" ] && break [ "$err" != "0" ] && ecode="$err" done return $ecode } 

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving, or modifying inner loops of scripts. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do wait -n err="$?" [ "$err" == "127" ] && break [ "$err" != "0" ] && ecode="$err" done return $ecode } 
added 4 characters in body
Source Link
Erik Aronesty
  • 13k
  • 6
  • 75
  • 48

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 until waitwhile -n;true; do   err="$?"  wait -n  if [ "$err" == "127"err="$?"  ]; then  [ "$err" == "127" ] && break fi [ "$err" != "0" ] && ecode="$err" done wait return $ecode } 

Wait for all jobs and return the exit code of the last failing job.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 until wait -n; do   err="$?"  if [ "$err" == "127" ]; then  break fi  ecode="$err" done wait return $ecode } 

Wait for all jobs and return the exit code of the last failing job. Unlike solutions above, this does not require pid saving. Just bg away, and wait.

function wait_ex { # this waits for all jobs and returns the exit code of the last failing job ecode=0 while true; do wait -n  err="$?"  [ "$err" == "127" ] && break [ "$err" != "0" ] && ecode="$err" done return $ecode } 
Source Link
Erik Aronesty
  • 13k
  • 6
  • 75
  • 48
Loading