modified spin function to accept input directly
This commit is contained in:
parent
26fe977ec9
commit
e3f8e5b219
1 changed files with 11 additions and 8 deletions
19
functions
19
functions
|
|
@ -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,14 +555,17 @@ 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
|
||||||
sp="/-\|"
|
# usage: spin "command [args]"
|
||||||
sc=0
|
|
||||||
spin() {
|
spin() {
|
||||||
printf "\b${sp:sc++:1}"
|
sp="/-\|"
|
||||||
((sc==${#sp})) && sc=0
|
sc=0
|
||||||
}
|
$@ &
|
||||||
endspin() {
|
_PID=&!
|
||||||
printf "\r%s\n" "$@"
|
while [ -d /proc/$_PID ] ; do
|
||||||
|
printf "\b${sp:sc++:1}"
|
||||||
|
((sc==${#sp})) && sc=0
|
||||||
|
done
|
||||||
|
printf "\r%s\n" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Example usage for above:
|
# Example usage for above:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue