From 3f6c1435a4cbdf73a65639b05898a01c0dfc21ac Mon Sep 17 00:00:00 2001 From: Pete Travis Date: Wed, 1 Oct 2014 11:33:51 -0600 Subject: we might need this sles10 stuff later --- .../bash-3.1-postpatch/examples/functions/isnum2 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scratch/bash-3.1-postpatch/examples/functions/isnum2 (limited to 'scratch/bash-3.1-postpatch/examples/functions/isnum2') diff --git a/scratch/bash-3.1-postpatch/examples/functions/isnum2 b/scratch/bash-3.1-postpatch/examples/functions/isnum2 new file mode 100644 index 0000000..e2e7a5f --- /dev/null +++ b/scratch/bash-3.1-postpatch/examples/functions/isnum2 @@ -0,0 +1,22 @@ +isnum2() +{ + case "$1" in + '[-+]' | '') return 1;; # empty or bare `-' or `+' + [-+]*[!0-9]*) return 1;; # non-digit with leading sign + [-+]*) return 0;; # OK + *[!0-9]*) return 1;; # non-digit + *) return 0;; # OK + esac +} + +# this one handles floating point +isnum3() +{ + case "$1" in + '') return 1;; # empty + *[!0-9.+-]*) return 1;; # non-digit, +, -, or . + *?[-+]*) return 1;; # sign as second or later char + *.*.*) return 1;; # multiple decimal points + *) return 0;; # OK + esac +} -- cgit