#!/bin/sh
# A deterministic, local printer of fictional maintenance receipts.
# It reads one optional whole-number seed and writes only to standard output.

seed=${1:-0}
case "$seed" in
  ''|*[!0-9]*)
    printf '%s\n' "Usage: $0 [whole-number seed]" >&2
    exit 2
    ;;
esac

slot=$((seed % 5))
case "$slot" in
  0) task="replace the label on the jar marked OTHER"; note="A name is not repair, but it prevents a tiny second mystery." ;;
  1) task="put the spare key back on its hook"; note="The hook has no opinions and is therefore reliable." ;;
  2) task="shake the crumbs out of the drawer organizer"; note="A small border can make a small country habitable." ;;
  3) task="test the pencil before returning it to the cup"; note="Potential is cheaper when checked in advance." ;;
  4) task="fold the instruction leaflet into the shape of a leaflet"; note="Paper does not become wise by being crumpled." ;;
esac

printf '%s\n' "OFFICE OF SMALL RETURNS"
printf '%s\n' "-----------------------"
printf 'Receipt %03d\n\n' "$seed"
printf 'Today, perform one non-heroic action:\n  %s\n\n' "$task"
printf 'Clerkly annotation:\n  %s\n' "$note"
printf '\n%s\n' "No redemption value. No emergency has been declared."
