You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
644 B
44 lines
644 B
#!/bin/bash
|
|
|
|
fail()
|
|
{
|
|
printf "${@}\n" >&2
|
|
exit 1
|
|
}
|
|
|
|
FRAMES=()
|
|
while [ -n "${1}" ]
|
|
do
|
|
case "${1}" in
|
|
-p)
|
|
PERIOD="${2}"
|
|
shift 2;;
|
|
-f)
|
|
FILE="${2}"
|
|
IFS="\n"
|
|
while read LINE
|
|
do
|
|
FRAMES+=("${LINE}")
|
|
done < "${FILE}"
|
|
shift 2;;
|
|
*)
|
|
SEPARATOR="${1:0:1}"
|
|
INPUT="${1:1}${SEPARATOR}"
|
|
while [ -n "${INPUT}" ]
|
|
do
|
|
FRAMES+=("${INPUT%%${SEPARATOR}*}")
|
|
INPUT="${INPUT#*${SEPARATOR}}"
|
|
done
|
|
shift;;
|
|
esac
|
|
done
|
|
[ -n "${PERIOD}" ] || PERIOD=0.2
|
|
[ -n "${FRAMES}" ] || fail "Syntax: ${0} [ -p PERIOD ] FRAMES"
|
|
N=0
|
|
|
|
while true
|
|
do
|
|
printf "\r${FRAMES[$N]}"
|
|
N=$(((N + 1) % ${#FRAMES[@]}))
|
|
sleep $PERIOD
|
|
done
|