Smaller spinner code

This commit is contained in:
deajan 2016-12-09 21:44:57 +01:00
parent 785c12b364
commit 4308678cc2
1 changed files with 7 additions and 28 deletions

View File

@ -2,7 +2,7 @@
#### OFUNCTIONS MINI SUBSET #### #### OFUNCTIONS MINI SUBSET ####
_OFUNCTIONS_VERSION=2.1 _OFUNCTIONS_VERSION=2.1
_OFUNCTIONS_BUILD=2016120901 _OFUNCTIONS_BUILD=2016120902
_OFUNCTIONS_BOOTSTRAP=true _OFUNCTIONS_BOOTSTRAP=true
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
@ -595,37 +595,16 @@ function LoadConfigFile {
CONFIG_FILE="$configFile" CONFIG_FILE="$configFile"
} }
_OFUNCTIONS_SPINNER='|/-\'
function Spinner { function Spinner {
if [ $_LOGGER_SILENT == true ] || [ "$_LOGGER_ERR_ONLY" == true ]; then if [ $_LOGGER_SILENT == true ] || [ "$_LOGGER_ERR_ONLY" == true ]; then
return 0 return 0
else
printf " [%c] " "$_OFUNCTIONS_SPINNER"
printf "\b\b\b\b\b\b"
_OFUNCTIONS_SPINNER=${_OFUNCTIONS_SPINNER#?}${_OFUNCTIONS_SPINNER%%???}
return 0
fi fi
case $_OFUNCTIONS_SPINNER_TOGGLE
in
1)
echo -n " \ "
echo -ne "\r"
_OFUNCTIONS_SPINNER_TOGGLE=2
;;
2)
echo -n " | "
echo -ne "\r"
_OFUNCTIONS_SPINNER_TOGGLE=3
;;
3)
echo -n " / "
echo -ne "\r"
_OFUNCTIONS_SPINNER_TOGGLE=4
;;
*)
echo -n " - "
echo -ne "\r"
_OFUNCTIONS_SPINNER_TOGGLE=1
;;
esac
} }
# Array to string converter, see http://stackoverflow.com/questions/1527049/bash-join-elements-of-an-array # Array to string converter, see http://stackoverflow.com/questions/1527049/bash-join-elements-of-an-array