2021-03-01 23:41:34 -05:00
|
|
|
#!/bin/sh
|
2021-02-14 18:36:09 -05:00
|
|
|
#
|
|
|
|
# "It isn't fair, my precious, is it,
|
|
|
|
# to ask us what it's got in it's
|
|
|
|
# nassty little pocketsess?"
|
2021-03-01 23:41:34 -05:00
|
|
|
# Gollum, The Hobbit, or There and Back Again
|
2021-02-14 18:36:09 -05:00
|
|
|
#
|
|
|
|
|
2021-03-12 19:59:17 -05:00
|
|
|
if [ ! -f 'patches/gollum.sh' ]
|
|
|
|
then
|
|
|
|
echo "We must be run from the project root dir, precious!"; exit 1
|
|
|
|
fi
|
2021-02-14 18:36:09 -05:00
|
|
|
|
2021-03-12 19:59:17 -05:00
|
|
|
ex=$(printf "%03d" $1)
|
|
|
|
echo "Nassssty exercise $ex..."
|
2021-02-14 18:36:09 -05:00
|
|
|
|
2021-03-12 19:59:17 -05: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-14 18:36:09 -05:00
|
|
|
|
2021-03-12 19:59:17 -05: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 15:57:20 -04:00
|
|
|
echo "Hissss! before: '$b'"
|
|
|
|
echo " after: '$a'"
|
|
|
|
echo " patch: '$p'"
|
2021-02-14 18:36:09 -05:00
|
|
|
|
2023-10-05 14:18:04 -04:00
|
|
|
diff -u $b $a > $p
|
2021-02-14 18:36:09 -05:00
|
|
|
|
|
|
|
cat $p
|