gollum.sh 712 B

1234567891011121314151617181920212223242526272829
  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!\tbefore: '$b'\n\t after: '$a'\n\t patch: '$p'\n"
  21. diff $b $a > $p
  22. cat $p