eowyn.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 run from the patches dir. Go there now if not already.
  16. cd $(dirname $0)
  17. pwd # Show it upon the screen so all shall be made apparent.
  18. # Create healed/ directory here if it doesn't already exist.
  19. mkdir -p healed
  20. # Cycle through all the little broken Zig applications.
  21. for broken in ../exercises/*.zig
  22. do
  23. # Remove the dir and extension, rendering the True Name.
  24. true_name=$(basename $broken .zig)
  25. patch_name="patches/$true_name.patch"
  26. if [[ -f $patch_name ]]
  27. then
  28. # Apply the bandages to the wounds, grow new limbs, let
  29. # new life spring into the broken bodies of the fallen.
  30. echo Healing $true_name...
  31. patch --output=healed/$true_name.zig $broken $patch_name
  32. else
  33. echo Cannot heal $true_name. Making empty patch.
  34. echo > $patch_name
  35. fi
  36. done
  37. # Return to the home of our ancestors.
  38. cd ..
  39. # Test the healed exercises. May the compiler have mercy upon us.
  40. zig build -Dhealed