mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-01-11 22:44:44 +00:00
Merge pull request #2705 from pi-hole/fix/chronometer-refresh-arg
Fix chronometer refresh incorrectly reading the long argument sleep time
This commit is contained in:
commit
6812e8880e
1 changed files with 15 additions and 16 deletions
|
@ -444,6 +444,9 @@ get_strings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
chronoFunc() {
|
chronoFunc() {
|
||||||
|
local extra_arg="$1"
|
||||||
|
local extra_value="$2"
|
||||||
|
|
||||||
get_init_stats
|
get_init_stats
|
||||||
|
|
||||||
for (( ; ; )); do
|
for (( ; ; )); do
|
||||||
|
@ -461,10 +464,8 @@ chronoFunc() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get refresh number
|
# Get refresh number
|
||||||
if [[ "$*" == *"-r"* ]]; then
|
if [[ "${extra_arg}" = "refresh" ]]; then
|
||||||
num="$*"
|
num="${extra_value}"
|
||||||
num="${num/*-r /}"
|
|
||||||
num="${num/ */}"
|
|
||||||
num_str="Refresh set for every $num seconds"
|
num_str="Refresh set for every $num seconds"
|
||||||
else
|
else
|
||||||
num_str=""
|
num_str=""
|
||||||
|
@ -473,7 +474,7 @@ chronoFunc() {
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# Remove exit message heading on third refresh
|
# Remove exit message heading on third refresh
|
||||||
if [[ "$count" -le 2 ]] && [[ "$*" != *"-e"* ]]; then
|
if [[ "$count" -le 2 ]] && [[ "${extra_arg}" != "exit" ]]; then
|
||||||
echo -e " ${COL_LIGHT_GREEN}Pi-hole Chronometer${COL_NC}
|
echo -e " ${COL_LIGHT_GREEN}Pi-hole Chronometer${COL_NC}
|
||||||
$num_str
|
$num_str
|
||||||
${COL_LIGHT_RED}Press Ctrl-C to exit${COL_NC}
|
${COL_LIGHT_RED}Press Ctrl-C to exit${COL_NC}
|
||||||
|
@ -521,10 +522,10 @@ chronoFunc() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle exit/refresh options
|
# Handle exit/refresh options
|
||||||
if [[ "$*" == *"-e"* ]]; then
|
if [[ "${extra_arg}" == "exit" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
if [[ "$*" == *"-r"* ]]; then
|
if [[ "${extra_arg}" == "refresh" ]]; then
|
||||||
sleep "$num"
|
sleep "$num"
|
||||||
else
|
else
|
||||||
sleep 5
|
sleep 5
|
||||||
|
@ -561,12 +562,10 @@ if [[ $# = 0 ]]; then
|
||||||
chronoFunc
|
chronoFunc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for var in "$@"; do
|
case "$1" in
|
||||||
case "$var" in
|
"-j" | "--json" ) jsonFunc;;
|
||||||
"-j" | "--json" ) jsonFunc;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
"-h" | "--help" ) helpFunc;;
|
"-r" | "--refresh" ) chronoFunc refresh "$2";;
|
||||||
"-r" | "--refresh" ) chronoFunc "$@";;
|
"-e" | "--exit" ) chronoFunc exit;;
|
||||||
"-e" | "--exit" ) chronoFunc "$@";;
|
* ) helpFunc "?";;
|
||||||
* ) helpFunc "?";;
|
esac
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
Loading…
Reference in a new issue