aboutsummaryrefslogtreecommitdiff
path: root/pb_number
blob: 40a96beb561754a4ba34934be1bf8809a42dc960 (plain) (blame)
1
2
3
4
5
6
7
8
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 ;}