source: trunk/third/bash/examples/functions/isnum2 @ 12959

Revision 12959, 482 bytes checked in by tb, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12958, which included commits to RCS files with non-trunk default branches.
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.