#!/bin/sh # # output a random quote from my quotes database # # Copyright © 1997–2008 martin f. krafft # Released under the terms of the Artistic Licence 2.0 # set -eu if [ ! -x "$(command -v fortune)" ]; then echo "E: fortune not installed" >&2 echo "This space unintentionally left blank" exit 1 fi QUOTES_FILE=${0%/*}/../.quotes/quotes QUOTES_HASH=${QUOTES_FILE}.dat if [ ! -f "$QUOTES_HASH" ] || [ "$QUOTES_HASH" -ot "$QUOTES_FILE" ]; then echo I: rebuilding quotes hash... >&2 strfile -s "$QUOTES_FILE" fi args= [ -n "${1:-}" ] && args="-i -m $@" eval exec fortune $args $QUOTES_FILE 2>/dev/null