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.
while [ 1 ]
case $state in
0) printf "-";;
1) printf "\\";;
2) printf "|";;
3) printf "/";;
if [ $state -eq 3 ]
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. ;-)