repo.or.cz
/
bash.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Patch-ID: bash41-003
[bash.git]
/
examples
/
functions
/
isvalidip
blob
0b2dafedfb558a02447accf529099fc5fdc513de
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
}