You can say:
set -o pipefail
Saying so would cause $?
to report the exit code of the last command in the pipeline to exit with a non-zero status.
Quoting from The Set Builtin:
pipefail
If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.
Additionally, the array PIPESTATUS
would report the return code of all the commands in the pipeline. Saying:
echo "${PIPESTATUS[@]}"
would list all those. For your example, it'd display 3 numbers, e.g.
1 0 0
if wget
failed.
Quoting from the manual:
PIPESTATUS
An array variable (see Arrays) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command).