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:
parent
2bf1916a34
commit
5b277eb855
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue