trap and kill animation properly

This commit is contained in:
ville rantanen
2018-11-23 21:12:34 +02:00
parent ab96989293
commit 0290371e73

View File

@@ -48,12 +48,13 @@ function siprefix() {
}
function animate() {
CHARS="|/-__-\\"
trap "trap - SIGTERM && kill -- -$$" EXIT SIGINT SIGTERM
CHARS=( "| " "/ " " _ " " \\" " |" " \\" " _ " "/ " )
i=0
while true; do
sleep 0.2
printf "\r%s\r" ${CHARS:$i:1} >&2
i=$(( (i + 1)%${#CHARS} ))
printf "\r %s\r" "${CHARS[$i]}" >&2
i=$(( (i + 1)%${#CHARS[@]} ))
done
}