.create_all_patches.sh 1.09 KiB
#!/bin/bash
#This is to be executed at the root folder of dumux-course, no input arguments required. The script creates patches for all exercises stored in the exercise/ folder and with a name starting with exercise-*
exerciseFolder=exercises/
# Iterate over all subdirectories
for exercise in $(find $exerciseFolder -maxdepth 1 -type d -name "exercise-*")
do
#crop path to get exercise name
exerciseName=${exercise%/} # this removes the trailing slash of the path - % removes smallest suffix matching the given pattern
exerciseName=${exercise#exercises/} # this remove the leading exercises/ of the path - # removes the smallest prefix matching the given pattern
#check if the exercise-folder exists. Should always exist, as we iterate over them
if [ ! -d exercises/$exerciseName ]
then
echo
echo "exercises/$exerciseName does NOT exist. Terminating."
exit 1
fi
echo "Generating diff for $exerciseName. Storing the patch file into patches/$exerciseName/$exerciseName.patch"
diff -ruN $exercise exercises/solution/$exerciseName > .patches/$exerciseName/$exerciseName.patch
done