X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/849106f7246e47bc077d7f3b8228cec717a8e63d..26f0533782d8c57fb95b8df4f55057edcbf17703:/unitproc/bktemp-checkInt diff --git a/unitproc/bktemp-checkInt b/unitproc/bktemp-checkInt deleted file mode 100644 index cfe396e..0000000 --- a/unitproc/bktemp-checkInt +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# Desc: Checks if arg is an integer - -#==BEGIN Define script parameters== -#===BEGIN Declare local script functions=== -yell() { echo "$0: $*" >&2; } # print script path and all args to stderr -die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status -try() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails -checkInt() { - # Desc: Checks if arg is integer - # Usage: checkInt arg - # Input: arg: integer - # Output: - return code 0 (if arg is integer) - # - return code 1 (if arg is not integer) - # Example: if ! checkInt $arg; then echo "not int"; fi; - # Version: 0.0.1 - local returnState - - #===Process Arg=== - if [[ $# -ne 1 ]]; then - die "ERROR:Invalid number of arguments:$#"; - fi; - - RETEST1='^[0-9]+$'; # Regular Expression to test - if [[ ! $1 =~ $RETEST1 ]] ; then - returnState="false"; - else - returnState="true"; - fi; - - #===Determine function return code=== - if [ "$returnState" = "true" ]; then - return 0; - else - return 1; - fi; -} # Checks if arg is integer - -#===END Declare local script functions=== -#==END Define script parameters== - -#==BEGIN test code== -if checkInt 4; then yell "success"; fi; -sleep 1; -if checkInt "foo"; then yell "success"; else yell "fail"; fi; -sleep 1; -if checkInt "foo" "bar" "baz" 1; then yell "success"; else yell "fail"; fi; -sleep 1; -if checkInt; then yell "success"; else yell "fail"; fi; -#==END test code== - -# Author: Steven Baltakatei Sandoval -# License: GPLv3+