gollum.sh 745 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. #
  3. # "It isn't fair, my precious, is it,
  4. # to ask us what it's got in it's
  5. # nassty little pocketsess?"
  6. # Gollum, The Hobbit, or There and Back Again
  7. #
  8. if [ ! -f 'patches/gollum.sh' ]
  9. then
  10. echo "We must be run from the project root dir, precious!"; exit 1
  11. fi
  12. ex=$(printf "%03d" $1)
  13. echo "Nassssty exercise $ex..."
  14. f=$(basename exercises/${ex}_*.zig .zig 2> /dev/null)
  15. b=exercises/$f.zig
  16. a=answers/$f.zig
  17. p=patches/patches/$f.patch
  18. if [ ! -f $b ]; then echo "No $f! We hates it!"; exit 1; fi
  19. if [ ! -f $a ]; then echo "No $a! Where is it? Where is the answer, precious?"; exit; fi
  20. echo "Hissss! before: '$b'"
  21. echo " after: '$a'"
  22. echo " patch: '$p'"
  23. diff -u $b $a > $p
  24. cat $p