utility

Aggregate test statuses

Application pattern: collect each independent test status, return nonzero if any required test failed. Not a special Bash builtin.

Formal Syntax & Structure

bash syntaxbash
if test_command; then ...; else ...; fi

Return Value

exit status

Application pattern: collect each independent test status, return nonzero if any required test failed. Not a special Bash builtin.

Working Example

Example Snippetbash
run_tests() {    local code failed=0    for code in 0 7 0; do        if ( exit "$code" ); then            printf 'pass\n'        else            printf 'fail=%s\n' "$?"            failed=1        fi    done    return "$failed"}if run_tests; then exit 1; else    printf 'aggregate=%s\n' "$?"fi
Bash Reference