eowyn.sh 1.6 KB

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