modified spin function to accept input directly

This commit is contained in:
pyr0ball 2023-03-07 15:44:00 -08:00
parent 26fe977ec9
commit e3f8e5b219

View file

@ -2,7 +2,7 @@
# pyr0ball script functions library # pyr0ball script functions library
# Initial Vars # Initial Vars
functionsrev=1.1.3 functionsrev=1.1.4
scriptname="${0##*/}" scriptname="${0##*/}"
rundir="${0%/*}" rundir="${0%/*}"
rundir_absolute=$(cd `dirname $0` && pwd) rundir_absolute=$(cd `dirname $0` && pwd)
@ -555,13 +555,16 @@ ctrl_c(){
# trap ctrl_c INT # Commented out by default to prevent abnormal background exits # trap ctrl_c INT # Commented out by default to prevent abnormal background exits
# Function for spinner status # Function for spinner status
# usage: spin "command [args]"
spin() {
sp="/-\|" sp="/-\|"
sc=0 sc=0
spin() { $@ &
_PID=&!
while [ -d /proc/$_PID ] ; do
printf "\b${sp:sc++:1}" printf "\b${sp:sc++:1}"
((sc==${#sp})) && sc=0 ((sc==${#sp})) && sc=0
} done
endspin() {
printf "\r%s\n" "$@" printf "\r%s\n" "$@"
} }