# write a status message $2, of type $1 (notice, ok, warning, error), to the
# status file descriptor 3.  If there isn't a status file descriptor, write
# the message to standard output.
status() {
  if { true >&3; } 2>/dev/null; then
    printf '%s %s\n' "$1" "$2" >&3
  else
    printf '(%s) %s\n' "$1" "$2"
  fi
}

# write an error message $1 to standard error, prefixed with the program
# name.
error() {
  printf '%s: %s\n' "$(basename "$0")" "$1" >&2
}

# output an error message $1, and exit with a failure status.
die() {
  error "$1"
  exit 1
}
