source: vendor/bash/3.1-p17/examples/functions/isnum2

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 482 bytes
Line 
1isnum2()
2{
3 case "$1" in
4 '[-+]' | '') return 1;; # empty or bare `-' or `+'
5 [-+]*[!0-9]*) return 1;; # non-digit with leading sign
6 [-+]*) return 0;; # OK
7 *[!0-9]*) return 1;; # non-digit
8 *) return 0;; # OK
9 esac
10}
11
12# this one handles floating point
13isnum3()
14{
15 case "$1" in
16 '') return 1;; # empty
17 *[!0-9.+-]*) return 1;; # non-digit, +, -, or .
18 *?[-+]*) return 1;; # sign as second or later char
19 *.*.*) return 1;; # multiple decimal points
20 *) return 0;; # OK
21 esac
22}
Note: See TracBrowser for help on using the repository browser.