title: Set return (exit) code in find, while loop
body: <p>I have something like this:   </p>
  
  <pre><code>find $1 | grep -E $2  | while read prom; do
              if [[ $prom =~ (cmd-given) ]];
              then
                  ...
                  RETURN_PATH=$PWD
                  cd $WORKING_PATH
                  ...
                  if [[ -s "stdout-delta" ]] || [[ -s "stderr-delta" ]] || [[ -s "status-delta" ]];
                  then
                      RET_ERROR=1
                      RESULT="FAILED"
                  else
                      RESULT="OK"
                  fi
                  ...
                  echo "$TEST: $RESULT\n" &gt; /dev/stderr
                  cd $RETURN_PATH
              fi
          done
  </code></pre>
  
  <p>I want to make test if in every folder that have cmd-given check for empty files x-delta. If any of these files is not empty I want to write FAILED and set return code to 1. But I want to check all folders so I think that I use variable, set it to 1 and at the end check if it is equal to 1 that exit 1 else exit 0. But there is problem, when I get out from that loop, I don´t have 1 in my variable. So how should I solve this?</p>