eowyn.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 $(which $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. if [[ -f $true_name.patch ]]
  26. then
  27. # Apply the bandages to the wounds, grow new limbs, let
  28. # new life spring into the broken bodies of the fallen.
  29. echo Healing $true_name...
  30. patch --output=healed/$true_name.zig $broken $true_name.patch
  31. else
  32. echo Cannot heal $true_name. Making empty patch.
  33. echo > $true_name.patch
  34. fi
  35. done
  36. # Return to the home of our ancestors.
  37. cd ..
  38. # Test the healed exercises. May the compiler have mercy upon us.
  39. zig build -Dhealed