#!/bin/sh -e
# Wrap all fortune quotes at 76 characters

which par >/dev/null 2>&1 || 
{ echo "'Par' program not found, aborting..." >/dev/null; exit 1; } 

for fortune in *fortunes; do
	if [ -f $fortune ] ; then
		mv $fortune $fortune.old
		cat $fortune.old | protect-quote.pl |
		par w72 P+%  | unprotect-quote.pl >$fortune
	fi
done

exit 0
