Thanks a lot for the valuable help.
I had a look at all pieces of code, and they all seem pretty long for what I am doing.
So based on that I just redid a tiny piece of code I am sharing with you.
#! /bin/bash
state=1
delay=0.5
printf "-"
sleep $delay
while [ 1 ]
do
printf "\b"
case $state in
0) printf "-";;
1) printf "\\";;
2) printf "|";;
3) printf "/";;
esac
if [ $state -eq 3 ]
then
state=0;
else
state=$((state+1));
fi
sleep $delay
done
Of course, this can work as a standalone code, but take out the bash line, and you can insert it easily in a script, and eventually shrink it a bit more.
The only thing is about the condition, which is now running forever, so have to get out your own condition for the stop.
Hope you'll find it useful. ;-)