Use ${PIPESTATUS[0]} to catch the error code of worker.sh

This commit is contained in:
probonopd authored and GitHub committed 2023-07-15 13:35:06 +02:00
1 parent a2ec519570
commit 4e7969814f
1 file changed
+1 -1
+1 -1
View File
@@ -76,7 +76,7 @@ jobs:
for FILE in $FILES; do
echo "$FILE"
bash -e code/worker.sh $(readlink -f "$FILE") 2>&1 | tee log.txt
EXIT_CODE=$?
EXIT_CODE=${PIPESTATUS[0]} # bashism; get the return code of the leftmost element of the pipe
if [ $EXIT_CODE -ne 0 ]; then
echo "worker.sh exited with a non-zero code: $EXIT_CODE"
exit $EXIT_CODE