mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-24 13:50:17 +00:00
Only execute spinner function if there is a tty
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
parent
c7108a632c
commit
8d1f286f30
1 changed files with 23 additions and 20 deletions
|
@ -1348,6 +1348,8 @@ check_database_integrity() {
|
|||
# Show a text spinner during a long process run
|
||||
#
|
||||
spinner(){
|
||||
# Show the spinner only if there is a tty
|
||||
if tty -s; then
|
||||
local PID=$! # PID of the most recent background process
|
||||
local spin="/-\|"
|
||||
local start=0
|
||||
|
@ -1361,7 +1363,7 @@ spinner(){
|
|||
|
||||
while [ -d /proc/$PID ]; do
|
||||
elapsed=$(( $(date +%s) - start ))
|
||||
# print the spinner only on screen (tty) - use hours only if needed
|
||||
# use hours only if needed
|
||||
if [ "$elapsed" -lt 3600 ]; then
|
||||
printf "\r${spin:i++%${#spin}:1} %02d:%02d" $((elapsed/60)) $((elapsed%60)) >"$(tty)"
|
||||
else
|
||||
|
@ -1372,6 +1374,7 @@ spinner(){
|
|||
|
||||
printf "\r" >"$(tty)" # Return to the begin of the line after completion (the spinner will be overwritten)
|
||||
tput cnorm > /dev/tty # Restore cursor visibility
|
||||
fi
|
||||
}
|
||||
|
||||
obfuscated_pihole_log() {
|
||||
|
|
Loading…
Reference in a new issue