Commit 084b3d06 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add isnumber function

parent 8667dee5
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# Author: Vitaly Lipatov <lav@etersoft.ru> # Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain # Public domain
filter_strip_spaces() filter_strip_spaces()
{ {
# possible use just # possible use just
...@@ -11,6 +12,12 @@ filter_strip_spaces() ...@@ -11,6 +12,12 @@ filter_strip_spaces()
sed -e "s|^ ||" | sed -e "s| \$||" sed -e "s|^ ||" | sed -e "s| \$||"
} }
# TODO: see etersoft-build-utils/tests/test_isnumber.sh
isnumber()
{
echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$"
}
strip_spaces() strip_spaces()
{ {
echo "$*" | filter_strip_spaces echo "$*" | filter_strip_spaces
......
#!/bin/sh #!/bin/sh
. `dirname $0`/../share/eterbuild/functions/common . `dirname $0`/../share/eterbuild/functions/common
#load_mod spec load_mod strings
check() check()
{ {
...@@ -9,12 +9,12 @@ check() ...@@ -9,12 +9,12 @@ check()
} }
# TODO: move to lib # TODO: move to lib
isnumber() #isnumber()
{ #{
#local num="$(("$*"))" # #local num="$(("$*"))"
echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$" # echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$"
#[ "$num" != "0" ] # #[ "$num" != "0" ]
} #}
check_arg() check_arg()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment