diff options
author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2023-10-05 19:18:20 +0000 |
---|---|---|
committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2023-10-05 19:18:20 +0000 |
commit | 1c7e35e193de241a80bdf020ae078083b64c4998 (patch) | |
tree | b6e644084edac8db9b4f69ff7063fc9ff3107b55 /patches/frodo.sh | |
parent | ca378251272f134e132397aa9eff41898061d410 (diff) | |
parent | 9003544446138c7a8da83c0725bfff20841476d9 (diff) |
Merge pull request 'changed the patch files that we can also use them with busybox for testing in Woodpecker' (#8) from woodpecker into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/8
Diffstat (limited to 'patches/frodo.sh')
-rwxr-xr-x | patches/frodo.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/patches/frodo.sh b/patches/frodo.sh new file mode 100755 index 0000000..a92642a --- /dev/null +++ b/patches/frodo.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# "How do you pick up the threads of an old life? +# How do you go on, when in your heart you begin +# to understand... there is no going back? +# There are some things that time cannot mend. +# Some hurts that go too deep, that have taken hold." +# Frodo, The Return of the King +# +# +# This script shall repair the patches for the little +# broken programs using the old patches in this directory +# first, to heal them and then create new and better +# patches, with Gollum's help. +# +set -e + +# We check ourselves before we wreck ourselves. +if [ ! -f patches/frodo.sh ] +then + echo "But I must be run from the project root directory." + exit 1 +fi + +# Create directory of answers if it doesn't already exist. +mkdir -p answers + +# Cycle through all the little broken Zig applications. +i=0 +for broken in exercises/*.zig +do + ((i=i+1)) + + # Remove the dir and extension, rendering the True Name. + true_name=$(basename "$broken" .zig) + patch_name="patches/patches/$true_name.patch" + healed_name="answers/$true_name.zig" + cp "$broken" "$healed_name" + # echo "$patch_name" + + 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 -i "$patch_name" "$healed_name" + + # Create new prescriptions... + echo Repairing "$patch_name"... + if [ "$true_name.patch" = "999_the_end.patch" ] + then + i=999 + fi + # with gollum's help! + ./patches/gollum.sh $i + else + echo Cannot repair "$true_name". No patch found. + fi +done + |