]> git.ipfire.org Git - thirdparty/bash.git/blob - examples/functions/isvalidip
Imported from ../bash-2.05b.tar.gz.
[thirdparty/bash.git] / examples / functions / isvalidip
1 # Thanks to Chris F. A. Johnson <c.f.a.johnson@rogers.com> for this one
2 is_validip()
3 {
4 case "$*" in
5 ""|*[!0-9.]*|*[!0-9]) return 1 ;;
6 esac
7
8 local IFS=.
9 set -- $*
10
11 [ $# -eq 4 ] &&
12 [ ${1:-666} -le 255 ] && [ ${2:-666} -le 255 ] &&
13 [ ${3:-666} -le 255 ] && [ ${4:-666} -le 254 ]
14 }