aboutsummaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2021-03-12 19:59:17 -0500
committerDave Gauer <dave@ratfactor.com>2021-03-12 19:59:17 -0500
commit83e235cf1bf87ec00af67d0d3ab63ba9cc329344 (patch)
tree0a1bab03330bebf474dd082864271a601c9140ab /patches
parent2e99488b0e076fdfcbe70d79e037e8db5797eb0c (diff)
downloadziglings-83e235cf1bf87ec00af67d0d3ab63ba9cc329344.tar.gz
ziglings-83e235cf1bf87ec00af67d0d3ab63ba9cc329344.tar.bz2
ziglings-83e235cf1bf87ec00af67d0d3ab63ba9cc329344.tar.xz
ziglings-83e235cf1bf87ec00af67d0d3ab63ba9cc329344.zip
Patch/test scripts now run from project root
This simplifies everything and makes everything good. (Shell scripts need to be as simple as possible for maximum compatibility.)
Diffstat (limited to 'patches')
-rwxr-xr-xpatches/eowyn.sh22
-rwxr-xr-xpatches/gollum.sh23
2 files changed, 25 insertions, 20 deletions
diff --git a/patches/eowyn.sh b/patches/eowyn.sh
index f450c0e..1ff3f75 100755
--- a/patches/eowyn.sh
+++ b/patches/eowyn.sh
@@ -13,19 +13,22 @@
# to convalesce in the healed directory.
#
-# We run from the patches dir. Go there now if not already.
-cd $(dirname $(realpath $0))
-pwd # Show it upon the screen so all shall be made apparent.
+# We check ourselves before we wreck ourselves.
+if [ ! -f 'patches/eowyn.sh' ]
+then
+ echo "But I must be run from the project root directory."
+ exit 1
+fi
-# Create healed/ directory here if it doesn't already exist.
-mkdir -p healed
+# Create directory of healing if it doesn't already exist.
+mkdir -p patches/healed
# Cycle through all the little broken Zig applications.
-for broken in ../exercises/*.zig
+for broken in exercises/*.zig
do
# Remove the dir and extension, rendering the True Name.
true_name=$(basename $broken .zig)
- patch_name="patches/$true_name.patch"
+ patch_name="patches/patches/$true_name.patch"
if [ -f $patch_name ]
@@ -33,14 +36,11 @@ do
# Apply the bandages to the wounds, grow new limbs, let
# new life spring into the broken bodies of the fallen.
echo Healing $true_name...
- patch --output=healed/$true_name.zig $broken $patch_name
+ patch --output=patches/healed/$true_name.zig $broken $patch_name
else
echo Cannot heal $true_name. No patch found.
fi
done
-# Return to the home of our ancestors.
-cd ..
-
# Test the healed exercises. May the compiler have mercy upon us.
zig build -Dhealed
diff --git a/patches/gollum.sh b/patches/gollum.sh
index b693083..495aa44 100755
--- a/patches/gollum.sh
+++ b/patches/gollum.sh
@@ -6,18 +6,23 @@
# Gollum, The Hobbit, or There and Back Again
#
-cd $(dirname $(realpath $0))
-f=$(basename ../exercises/$1*.zig .zig 2> /dev/null)
-b=../exercises/$f.zig
-a=../answers/$f.zig
-p=patches/$f.patch
+if [ ! -f 'patches/gollum.sh' ]
+then
+ echo "We must be run from the project root dir, precious!"; exit 1
+fi
-printf "\tf: '$f'\n\tb: '$b'\n\ta: '$a'\n"
+ex=$(printf "%03d" $1)
+echo "Nassssty exercise $ex..."
-if [ ! -f $b ]; then echo "We hates it!"; exit 1; fi
-if [ ! -f $a ]; then echo "Where is it? Where is the answer, precious?"; exit; fi
+f=$(basename exercises/${ex}_*.zig .zig 2> /dev/null)
+b=exercises/$f.zig
+a=answers/$f.zig
+p=patches/patches/$f.patch
-echo Hisssss!
+if [ ! -f $b ]; then echo "No $f! We hates it!"; exit 1; fi
+if [ ! -f $a ]; then echo "No $a! Where is it? Where is the answer, precious?"; exit; fi
+
+echo "Hissss!\tbefore: '$b'\n\t after: '$a'\n\t patch: '$p'\n"
diff $b $a > $p