ddns-scripts: refactor get_uptime() and avoid cat in sub-shell

no sub-shell is spawned to get uptime.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald 2024-11-28 03:43:33 +01:00 committed by Florian Eckert
parent 2bf1916a34
commit 5b277eb855
1 changed files with 3 additions and 3 deletions

View File

@ -1210,9 +1210,9 @@ get_registered_ip() {
get_uptime() {
# $1 Variable to store result in
[ $# -ne 1 ] && write_log 12 "Error calling 'verify_host_port()' - wrong number of parameters"
local __UPTIME=$(cat /proc/uptime)
eval "$1=\"${__UPTIME%%.*}\""
[ $# -ne 1 ] && write_log 12 "Error calling 'get_uptime()' - requires exactly 1 argument."
read -r uptime < /proc/uptime
eval "$1=\"${uptime%%.*}\""
}
trap_handler() {