Skip to content

Commit

Permalink
fix exit/error detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Nov 20, 2024
1 parent f87e6fc commit 5996cdf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion resources/sample-each-dataset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ print(depth)
#######################################################################################
# Run!

export GLOBAL_ERROR_FLAG=0

MAX_REACHED_CODE=2

num_processed=0
Expand Down Expand Up @@ -120,6 +122,7 @@ process_dataset() {
else
echo "Error: Failed to process $dataset_dir" >&2
echo "$error_output" >&2
export GLOBAL_ERROR_FLAG=1
return 1 # Error! Stop processing datasets
fi
else
Expand All @@ -137,7 +140,13 @@ find "$BASE_PATH" \
-mindepth "$depth_to_datasets" \
-maxdepth "$depth_to_datasets" \
-type d \
-exec bash -c 'process_dataset "$0" || exit 1' {} \; || exit 1
-exec bash -c 'process_dataset "$0"' {} \;

# Check if any errors were flagged
if [ "$GLOBAL_ERROR_FLAG" -ne 0 ]; then
echo "Exiting with error (see above)." >&2
exit 1
fi

#######################################################################################

Expand Down

0 comments on commit 5996cdf

Please sign in to comment.