diff options
author | Pete Travis <immanetize@fedoraproject.org> | 2014-09-26 14:42:22 -0600 |
---|---|---|
committer | Pete Travis <immanetize@fedoraproject.org> | 2014-09-26 14:42:22 -0600 |
commit | 46c50fce0354d81d347a8055314a688fc8aa9f52 (patch) | |
tree | b7f6c49e1225f949a9c21da6afa52fd04a2484fd /scratch/bash-3.1/examples/functions/isvalidip | |
parent | fe5673aed2053463a7164ec5e7b609877340c0fa (diff) | |
download | rpmbuild-obs-product.tar.gz rpmbuild-obs-product.tar.xz rpmbuild-obs-product.zip |
bash sourcesobs-product
Diffstat (limited to 'scratch/bash-3.1/examples/functions/isvalidip')
-rw-r--r-- | scratch/bash-3.1/examples/functions/isvalidip | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scratch/bash-3.1/examples/functions/isvalidip b/scratch/bash-3.1/examples/functions/isvalidip new file mode 100644 index 0000000..0b2dafe --- /dev/null +++ b/scratch/bash-3.1/examples/functions/isvalidip @@ -0,0 +1,14 @@ +# Thanks to Chris F. A. Johnson <c.f.a.johnson@rogers.com> for this one +is_validip() +{ + case "$*" in + ""|*[!0-9.]*|*[!0-9]) return 1 ;; + esac + + local IFS=. + set -- $* + + [ $# -eq 4 ] && + [ ${1:-666} -le 255 ] && [ ${2:-666} -le 255 ] && + [ ${3:-666} -le 255 ] && [ ${4:-666} -le 254 ] +} |