aboutsummaryrefslogtreecommitdiff
path: root/pb_number
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-05-17 09:04:10 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-05-17 09:04:10 +0200
commit6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9 (patch)
tree7c505f5dcfcf93168079c772656292433d8bf29e /pb_number
parentde9249cc1b768687daa2a41e6a05455759890129 (diff)
downloadbashlib-6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9.tar.gz
bashlib-6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9.tar.bz2
bashlib-6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9.zip
update
Diffstat (limited to 'pb_number')
-rwxr-xr-xpb_number9
1 files changed, 9 insertions, 0 deletions
diff --git a/pb_number b/pb_number
new file mode 100755
index 0000000..40a96be
--- /dev/null
+++ b/pb_number
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+#--- is number functions
+# https://stackoverflow.com/questions/806906/how-do-i-test-if-a-variable-is-a-number-in-bash/806923#806923
+
+pb_isuint() { case $1 in '' | *[!0-9]* ) return 1;; esac ;}
+pb_isint() { case ${1#[-+]} in '' | *[!0-9]* ) return 1;; esac ;}
+pb_isunum() { case $1 in '' | . | *[!0-9.]* | *.*.* ) return 1;; esac ;}
+pb_isnum() { case ${1#[-+]} in '' | . | *[!0-9.]* | *.*.* ) return 1;; esac ;}