That is way over-engineered for something that could be done with a 10 lines of bash:
diff2mail() {
a=$($@)
while true; do
b=$($@)
if [ "$a" != "$b" ]; then
echo "$a -> $b" | mail -s "$@ changed" 'root@example.com'
return
fi
sleep 1
done
}
diff2mail ls /tmp
And for a lot of stuff it's even shorter than that: make && x="is done" || x="has failed"; echo "build $x" | mail root