#!/bin/bash
# sleep_log.sh - log the time remaining in a sleep

# I'm experimenting with sourceable functions, that we can also run directly.

. ucm

sleep_log() {

local d=${1:-10} step=${2:-10}
if [ "$step" -gt "$d" ]; then
	step="$d"
fi
while [ "$d" -gt 0 ]; do
	echo -n "$d " >&2
	sleep "$step"
	d=$[d-step]
done
echo >&2

}

if is_main; then sleep_log "$@"; fi
