# SccsId[] = "%W% (USL function) %G%"
II_name="ISINT"
if [ ".${SECONDS}" = "." ]; then # Bourne function already loaded?
[ ."`set|egrep '^$II_name\(\)\{$'`" != . ] && II_loaded=1
else # Korn or Bash shell and function already loaded?
if [ `expr "\`uname -s\`" : "[Ll][Ii][Nn][Uu][Xx]"` -eq 0 ]; then
[ ."`typeset +f|awk '/^'$II_name'[=\(]?/'`" != . ] && II_loaded=1
else # Linux
[ ."`typeset -F|awk '/^'$II_name'[=\(]?/'`" != . ] && II_loaded=1
fi
fi
if [ 0${II_loaded} -eq 0 ]; then
#----------------------------------------------------------------------#
ISINT() # Function documentation located at bottom. #
#----------------------------------------------------------------------#
{ [ ."${AWK}" = . ] && { { [ -x /usr/bin/nawk ] && AWK=/usr/bin/nawk; } \
|| { [ -x /bin/gawk ] && AWK=/bin/gawk ; } \
|| { [ -x /usr/bin/awk ] && AWK=/usr/bin/awk ; }; }
if [ ."$1" = ."-s" ]; then
shift # Shift past option its following argument
II_signed_int=$true
else
II_signed_int=$false
fi
if [ $# -eq 1 ]; then
if [ $II_signed_int -eq $true ]; then
$AWK 'BEGIN {exit (ARGV[1] ~ /^[\-+]*[0-9]+$/) ? 1 : 0}' $1
else
$AWK 'BEGIN {exit (ARGV[1] ~ /^[0-9]+$/) ? 1 : 0}' $1
fi
return $?
fi
if [ .${SHLIB} = . ]; then SHLIB=/usr/local/scripts; export SHLIB; fi
. $SHLIB/email_msg.sh # Calls $SHLIB/exit.sh
II_ID="$script_name($II_name)"
#------------------------------------------------------------#
# If the following variables are not set, use these defaults.#
#------------------------------------------------------------#
: ${script_name:=`basename $0`}
: ${sp:=" "}
EMAIL_MSG "ERROR (Function) $II_ID" \
"${sp}Insufficient args.\n" \
"${sp}Usage: $II_name [-s] num" \
"${sp} -s = Allows signed integer." \
"${sp} num = a string we're to test for numeric" \
"${sp} truth (unsigned integer by default;" \
"${sp} optionally, signed integer)."
return 2
} # "II_" prefix identifies this function's local variables.
fi
#======================================================================#
# D O C U M E N T A T I O N #
#======================================================================#
# #
# Author: Bob Orlando #
# #
# Date: January 20, 1997 #
# #
# Program ID: isint.sh #
# #
# Usage: ISINT [-s] number #
# -s = Allows signed integer #
# (otherwise, to defaults to unsigned int). #
# #
# Purpose: Determine if the value passed is an integer or no. #
# #
# Globals: No global variables are assigned in this function. #
# "II_" prefix identifies local function variables. #
# #
# Exit_status: Function error (e.g. user supplies invalid arguments) #
# return 2. Otherwise returns true or false (1 or 0). #
# #
# Calls: EMAIL_MSG library function. #
# #
# Notes: .................................................... #
# .................................................... #
# #
# Modified: 2004-04-02 Bob Orlando #
# v1.9 * Expand $AWK testing and assignment. #
# #
# 2004-03-03 Bob Orlando #
# v1.8 * Change set|egrep|awk to just set|egrep. #
# #
#----------------------------------------------------------------------#
|