Skip to content

Commit

Permalink
add: fast fail
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronaut committed Oct 12, 2024
1 parent bcc205f commit 7b8f738
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion diffdir
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fi
# Assign the arguments to meaningful variable names
SOURCE_DIR=$1
DESTINATION_DIR=$2
FAST_FAIL=false

# Check if the source directory exists
if [ ! -d "$SOURCE_DIR" ]; then
Expand Down Expand Up @@ -54,7 +55,7 @@ if diff <(find "$SOURCE_DIR" \( $FIND_CONDITION \)|sed "s|$SOURCE_DIR||") <(find
else
echo "Differences between the $SOURCE_DIR and $DESTINATION_DIR found."
diff <(find "$SOURCE_DIR" \( $FIND_CONDITION \)|sed "s|$SOURCE_DIR||") <(find "$DESTINATION_DIR" \( $FIND_CONDITION \)|sed "s|$DESTINATION_DIR||")
EXIT_CODE=1
exit 1
fi

while read -r FILE_IN_SOURCE_DIR; do
Expand All @@ -66,10 +67,16 @@ while read -r FILE_IN_SOURCE_DIR; do
:
else
echo "File $FILE_IN_SOURCE_DIR and $FILE_IN_DESTINATION_DIR are different"
if [ "$FAST_FAIL" = true ] ; then
exit 1
fi
EXIT_CODE=1
fi
else
echo "File $FILE_IN_DESTINATION_DIR does not exist in directory $DESTINATION_DIR."
if [ "$FAST_FAIL" = true ] ; then
exit 1
fi
EXIT_CODE=1
fi
done < <(find "$SOURCE_DIR" -type f)
Expand Down

0 comments on commit 7b8f738

Please sign in to comment.