eowyn.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. #
  3. # "I will be a shieldmaiden no longer,
  4. # nor vie with the great Riders, nor
  5. # take joy only in the songs of slaying.
  6. # I will be a healer, and love all things
  7. # that grow and are not barren."
  8. # Éowyn, The Return of the King
  9. #
  10. #
  11. # This script shall heal the little broken programs
  12. # using the patches in this directory and convey them
  13. # to convalesce in the healed directory.
  14. #
  15. set -e
  16. # We run from the patches dir. Go there now if not already.
  17. cd $(dirname $(realpath $0))
  18. pwd # Show it upon the screen so all shall be made apparent.
  19. # Create healed/ directory here if it doesn't already exist.
  20. mkdir -p healed
  21. # Cycle through all the little broken Zig applications.
  22. for broken in ../exercises/*.zig
  23. do
  24. # Remove the dir and extension, rendering the True Name.
  25. true_name=$(basename $broken .zig)
  26. patch_name="patches/$true_name.patch"
  27. if [[ -f $patch_name ]]
  28. then
  29. # Apply the bandages to the wounds, grow new limbs, let
  30. # new life spring into the broken bodies of the fallen.
  31. echo Healing $true_name...
  32. patch --output=healed/$true_name.zig $broken $patch_name
  33. else
  34. echo Cannot heal $true_name. Making empty patch.
  35. echo > $patch_name
  36. fi
  37. done
  38. # Return to the home of our ancestors.
  39. cd ..
  40. # Test the healed exercises. May the compiler have mercy upon us.
  41. zig build -Dhealed