xargs runs a command many times, but it gives back one exit code. Knowing what that code means is how a script finds out that one of the runs went wrong.
find . -name '*.gz' -print0 | xargs -0 -n 1 gzip -t
echo $?
If every run of gzip -t worked, xargs exits with 0. If any run failed with a status from 1 to 125, xargs keeps going with the rest and exits with 123 at the end. Two runs where one fails give 123.
I think a few other codes are worth knowing. When a command exits with 255, xargs stops right away and returns 124; that’s a way for a script to say “abort everything”. 127 means the command wasn’t found, and 126 that it was found but couldn’t be run. A command killed by a signal gives 125.
So in a script, this is enough to notice a failure:
if ! find . -name '*.gz' -print0 | xargs -0 -r gzip -t; then
echo 'at least one archive is damaged' >&2
fi
Two limits. The code says something failed, not which run, so let the command print its own errors. And in a pipeline, $? is the status of the last command; if find fails before it, you only see it with set -o pipefail.
Further reading: xargs(1) manual page, GNU findutils manual: Invoking xargs