mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +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
@ -1348,6 +1348,8 @@ check_database_integrity() {
|
|||||||
# Show a text spinner during a long process run
|
# Show a text spinner during a long process run
|
||||||
#
|
#
|
||||||
spinner(){
|
spinner(){
|
||||||
|
# Show the spinner only if there is a tty
|
||||||
|
if tty -s; then
|
||||||
local PID=$! # PID of the most recent background process
|
local PID=$! # PID of the most recent background process
|
||||||
local spin="/-\|"
|
local spin="/-\|"
|
||||||
local start=0
|
local start=0
|
||||||
@ -1361,7 +1363,7 @@ spinner(){
|
|||||||
|
|
||||||
while [ -d /proc/$PID ]; do
|
while [ -d /proc/$PID ]; do
|
||||||
elapsed=$(( $(date +%s) - start ))
|
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
|
if [ "$elapsed" -lt 3600 ]; then
|
||||||
printf "\r${spin:i++%${#spin}:1} %02d:%02d" $((elapsed/60)) $((elapsed%60)) >"$(tty)"
|
printf "\r${spin:i++%${#spin}:1} %02d:%02d" $((elapsed/60)) $((elapsed%60)) >"$(tty)"
|
||||||
else
|
else
|
||||||
@ -1372,6 +1374,7 @@ spinner(){
|
|||||||
|
|
||||||
printf "\r" >"$(tty)" # Return to the begin of the line after completion (the spinner will be overwritten)
|
printf "\r" >"$(tty)" # Return to the begin of the line after completion (the spinner will be overwritten)
|
||||||
tput cnorm > /dev/tty # Restore cursor visibility
|
tput cnorm > /dev/tty # Restore cursor visibility
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
obfuscated_pihole_log() {
|
obfuscated_pihole_log() {
|
||||||
|
Loading…
Reference in New Issue
Block a user