eowyn.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  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. # We check ourselves before we wreck ourselves.
  16. if [ ! -f 'patches/eowyn.sh' ]
  17. then
  18. echo "But I must be run from the project root directory."
  19. exit 1
  20. fi
  21. # Create directory of healing if it doesn't already exist.
  22. mkdir -p patches/healed
  23. # Cycle through all the little broken Zig applications.
  24. for broken in exercises/*.zig
  25. do
  26. # Remove the dir and extension, rendering the True Name.
  27. true_name=$(basename $broken .zig)
  28. patch_name="patches/patches/$true_name.patch"
  29. if [ -f $patch_name ]
  30. then
  31. # Apply the bandages to the wounds, grow new limbs, let
  32. # new life spring into the broken bodies of the fallen.
  33. echo Healing $true_name...
  34. patch --output=patches/healed/$true_name.zig $broken $patch_name
  35. else
  36. echo Cannot heal $true_name. No patch found.
  37. fi
  38. done
  39. # Test the healed exercises. May the compiler have mercy upon us.
  40. zig build -Dhealed