diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-02-25 20:36:50 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-02-25 20:36:50 -0500 |
commit | 4539d736f1aff232857a854fd2a68df0c98d9f34 (patch) | |
tree | 841c9a36d28c9a4d61c1b2d79524ccbe5f5c5029 /examples/functions/isnum.bash | |
parent | f281b8f4f8936b2713966274d9f8508a9f0910e4 (diff) | |
download | android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.tar.gz android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.tar.bz2 android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.zip |
prep for bash-4.3 release
Diffstat (limited to 'examples/functions/isnum.bash')
-rw-r--r-- | examples/functions/isnum.bash | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/examples/functions/isnum.bash b/examples/functions/isnum.bash deleted file mode 100644 index b733965..0000000 --- a/examples/functions/isnum.bash +++ /dev/null @@ -1,52 +0,0 @@ -#From: jrmartin@rainey.blueneptune.com (James R. Martin) -#Newsgroups: comp.unix.shell -#Subject: Re: testing user input on numeric or character value -#Date: 26 Nov 1997 01:28:43 GMT - -# isnum returns True if its argument is a valid number, -# and False (retval=1) if it is any other string. -# The first pattern requires a digit before the decimal -# point, and the second after the decimal point. - -# BASH NOTE: make sure you have executed `shopt -s extglob' before -# trying to use this function, or it will not work - -isnum() # string -{ - case $1 in - ?([-+])+([0-9])?(.)*([0-9])?([Ee]?([-+])+([0-9])) ) - return 0;; - ?([-+])*([0-9])?(.)+([0-9])?([Ee]?([-+])+([0-9])) ) - return 0;; - *) return 1;; - esac -} - -isnum2() # string -{ - case $1 in - ?([-+])+([[:digit:]])?(.)*([[:digit:]])?([Ee]?([-+])+([[:digit:]])) ) - return 0;; - ?([-+])*([[:digit:]])?(.)+([[:digit:]])?([Ee]?([-+])+([[:digit:]])) ) - return 0;; - *) return 1;; - esac -} - -isint() # string -{ - case $1 in - ?([-+])+([0-9]) ) - return 0;; - *) return 1;; - esac -} - -isint2() # string -{ - case $1 in - ?([-+])+([[:digit:]]) ) - return 0;; - *) return 1;; - esac -} |