This function return the absolute value of a given number.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.util | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/src/functions/functions.util b/src/functions/functions.util index 4b6f956..699026d 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -268,6 +268,16 @@ uuid() { echo $(</proc/sys/kernel/random/uuid) }
+abs() { + local val=${1} + + if [ ${val} -lt 0 ]; then + (( val *= -1 )) + fi + + echo ${val} +} + rand() { local uuid="$(uuid)" echo "${uuid//-/}"