Get exit code of process substitution with pipe into while loop
问题 The following script calls another program reading its output in a while loop (see Bash - How to pipe input to while loop and preserve variables after loop ends): while read -r col0 col1; do # [...] done < <(other_program [args ...]) How can I check for the exit code of other_program to see if the loop was executed properly? 回答1: Note: ls -d / /nosuch is used as an example command below, because it fails (exit code 1 ) while still producing stdout output ( / ) (in addition to stderr output).