2021-03-02 05:41:34 +01:00
|
|
|
#!/bin/sh
|
2021-02-15 00:36:09 +01:00
|
|
|
#
|
|
|
|
# "It isn't fair, my precious, is it,
|
|
|
|
# to ask us what it's got in it's
|
|
|
|
# nassty little pocketsess?"
|
2021-03-02 05:41:34 +01:00
|
|
|
# Gollum, The Hobbit, or There and Back Again
|
2021-02-15 00:36:09 +01:00
|
|
|
#
|
|
|
|
|
2021-03-13 01:59:17 +01:00
|
|
|
if [ ! -f 'patches/gollum.sh' ]
|
|
|
|
then
|
|
|
|
echo "We must be run from the project root dir, precious!"; exit 1
|
|
|
|
fi
|
2021-02-15 00:36:09 +01:00
|
|
|
|
2021-03-13 01:59:17 +01:00
|
|
|
ex=$(printf "%03d" $1)
|
|
|
|
echo "Nassssty exercise $ex..."
|
2021-02-15 00:36:09 +01:00
|
|
|
|
2021-03-13 01:59:17 +01:00
|
|
|
f=$(basename exercises/${ex}_*.zig .zig 2> /dev/null)
|
|
|
|
b=exercises/$f.zig
|
|
|
|
a=answers/$f.zig
|
|
|
|
p=patches/patches/$f.patch
|
2021-02-15 00:36:09 +01:00
|
|
|
|
2021-03-13 01:59:17 +01:00
|
|
|
if [ ! -f $b ]; then echo "No $f! We hates it!"; exit 1; fi
|
|
|
|
if [ ! -f $a ]; then echo "No $a! Where is it? Where is the answer, precious?"; exit; fi
|
|
|
|
|
2022-07-31 21:57:20 +02:00
|
|
|
echo "Hissss! before: '$b'"
|
|
|
|
echo " after: '$a'"
|
|
|
|
echo " patch: '$p'"
|
2021-02-15 00:36:09 +01:00
|
|
|
|
|
|
|
diff $b $a > $p
|
|
|
|
|
|
|
|
cat $p
|