From: Michael Tremer Date: Wed, 7 Jun 2017 16:48:40 +0000 (+0200) Subject: device: Return speed only if a valid (positive) value X-Git-Tag: 009~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d2d02da81284fa9a67e829844218b1a86ebccc4;p=network.git device: Return speed only if a valid (positive) value Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.device b/src/functions/functions.device index 5500dc87..008891d4 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -860,7 +860,12 @@ device_get_tx_errors() { device_get_speed() { local device=${1} - __device_get_file ${device} speed + local speed=$(__device_get_file ${device} speed) + + # Don't return anything for negative values + [ ${speed} -lt 0 ] && return ${EXIT_ERROR} + + print "${speed}" } device_get_duplex() {