chiark / gitweb /
check, rcheck: Propagate exit status better; capture lines more precisely.
[rcheck] / check
diff --git a/check b/check
index 92965e3..74c7f80 100755 (executable)
--- a/check
+++ b/check
@@ -4,17 +4,26 @@
 
 set -e
 
+exec 4>&1
+rc=0
 for check in check.d/[!#]*[!~]; do
-  { { { set +e; "$check"; rc=$?; set -e
-       case $rc in 0) ;; *) echo >&2 "failed (rc = $rc)" ;; esac
-    } >&3; } 2>&1 |
-    sed 's/^/E: /'
-  } 3>&1 | {
-    if read line; then
-      echo "## ${check##*/}"
-      echo "$line"
-      cat
-      echo
-    fi
-  }
+  nrc=$(
+    exec 5>&1
+    { { { set +e; "$check"; rc=$?; set -e
+         echo $rc >&5
+         case $rc in 0) ;; *) echo >&2 "failed (rc = $rc)" ;; esac
+      } >&3; } 2>&1 |
+      sed 's/^/E: /'
+    } 3>&1 | {
+      if IFS= read -r line; then
+       echo "## ${check##*/}"
+       echo "$line"
+       cat
+       echo
+      fi
+    } >&4
+  )
+  if [ $nrc -gt $rc ]; then rc=$nrc; fi
 done
+
+exit $rc