diff --git a/inc_pluginfunctions b/inc_pluginfunctions index 55b1b19dafb370ce2931f14c2f491e0c614cf3da..c7a7dcf9e5111c879202fd1c216211cc3db0a5ff 100644 --- a/inc_pluginfunctions +++ b/inc_pluginfunctions @@ -320,6 +320,12 @@ function ph.toUnit(){ local _value=$1 local _unit=$2 local _digits=${3:-0} + local _dots + + if [ "$_value" -eq "0" ]; then + echo "0" + return 0 + fi local _multiply; _multiply=$( ph._getExp "$_value" ) local _divisor; _divisor=$( ph._getExp "$_unit" ) @@ -327,7 +333,6 @@ function ph.toUnit(){ local _bc _bc="bc" - local _dots test $_digits -gt 0 && _dots=$( yes "." 2>/dev/null | head -$_digits | tr -d "\n" ) test $_digits -gt 0 && _bc+=" -l | grep -o '.*\\.${_dots}'"