aboutsummaryrefslogtreecommitdiff
path: root/patches/eowyn.sh
blob: f9e7479de2a3ca5675b5b2d2e169539984cdf0bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
#
#     "I will be a shieldmaiden no longer,
#      nor vie with the great Riders, nor
#      take joy only in the songs of slaying.
#      I will be a healer, and love all things
#      that grow and are not barren."
#             Éowyn, The Return of the King
#
#
# This script shall heal the little broken programs
# using the patches in this directory and convey them
# 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.

# Create healed/ directory here if it doesn't already exist.
mkdir -p healed

# Cycle through all the little broken Zig applications.
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"


    if [[ -f $patch_name ]]
    then
        # 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
    else
        echo Cannot heal $true_name. Making empty patch.
        echo > $patch_name
    fi
done

# Return to the home of our ancestors.
cd ..

# Test the healed exercises. May the compiler have mercy upon us.
zig build -Dhealed