Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > d182ba7656bc9d858108359beee647e7 > files > 92

bash-doc-4.1.7-4.fc14.x86_64.rpm

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
}