Eric Blake <eblake@xxxxxxxxxx> wrote: > > Generally not possible using only POSIX constructs (bash's 'set -o > pipefail' and '${PIPESTATUS[@]}' are extensions). But what you _can_ do > is play with exec to be able to propagate non-zero status from a > particular portion of a pipeline through a temporary variable or file: > > $ exec 3>&1 # duplicate original stdout > $ result=$( > exec 4>&1 >&3 3>&- # move cmd subst stdout, and restore original > { ./main.sh; echo $? >&4 # run command, and record its status > } | head -n 3) > $ echo $? # status from head > $ echo $result # status from ./main.sh > $ exec 3>&- Another way is to use fifos. Cheers, -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html