IsInteger should be part of ofunctions micro/mini
This commit is contained in:
parent
996e6251e1
commit
6e7b99debb
|
@ -347,6 +347,28 @@ function Logger {
|
||||||
}
|
}
|
||||||
#### Logger SUBSET END ####
|
#### Logger SUBSET END ####
|
||||||
|
|
||||||
|
#### IsInteger SUBSET ####
|
||||||
|
# Function is busybox compatible since busybox ash does not understand direct regex, we use expr
|
||||||
|
function IsInteger {
|
||||||
|
local value="${1}"
|
||||||
|
|
||||||
|
if type expr > /dev/null 2>&1; then
|
||||||
|
expr "$value" : "^[0-9]\+$" > /dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo 1
|
||||||
|
else
|
||||||
|
echo 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ $value =~ ^[0-9]+$ ]]; then
|
||||||
|
echo 1
|
||||||
|
else
|
||||||
|
echo 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#### IsInteger SUBSET END ####
|
||||||
|
|
||||||
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
|
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
|
||||||
function KillChilds {
|
function KillChilds {
|
||||||
local pid="${1}" # Parent pid to kill childs
|
local pid="${1}" # Parent pid to kill childs
|
||||||
|
@ -1317,28 +1339,6 @@ function IsNumericExpand {
|
||||||
echo $(IsNumeric "$value")
|
echo $(IsNumeric "$value")
|
||||||
}
|
}
|
||||||
|
|
||||||
#### IsInteger SUBSET ####
|
|
||||||
# Function is busybox compatible since busybox ash does not understand direct regex, we use expr
|
|
||||||
function IsInteger {
|
|
||||||
local value="${1}"
|
|
||||||
|
|
||||||
if type expr > /dev/null 2>&1; then
|
|
||||||
expr "$value" : "^[0-9]\+$" > /dev/null 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo 1
|
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ $value =~ ^[0-9]+$ ]]; then
|
|
||||||
echo 1
|
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
#### IsInteger SUBSET END ####
|
|
||||||
|
|
||||||
#### HumanToNumeric SUBSET ####
|
#### HumanToNumeric SUBSET ####
|
||||||
# Converts human readable sizes into integer kilobyte sizes
|
# Converts human readable sizes into integer kilobyte sizes
|
||||||
# Usage numericSize="$(HumanToNumeric $humanSize)"
|
# Usage numericSize="$(HumanToNumeric $humanSize)"
|
||||||
|
|
Loading…
Reference in New Issue