#!/usr/bin/env etsh : : etsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 959078fb7de9e42d0fc2c7665e0842461bd67714 $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " Compare integer1 against integer2 according to the specified operator. " : " Exit with a zero status (true) if the comparison is true, or exit with " : " a non-zero status (false) if the comparison is false. " : : " usage: intcmp integer1 {-eq | -ne | -gt | -ge | -lt | -le} integer2 " : : " Check for correct usage. " : >>$0'' <'' ; killer $0 intcmp : >>$1'' <'' ; : >>$2'' <'' ; : >>$3'' <'' if $# != 3 if { exit } \ pusage $0 '"integer1 {-eq | -ne | -gt | -ge | -lt | -le} integer2"' if X$1 != X0 -a ! { \ expr //$1 : '//[1-9][0-9]*' \> 2 \& //$1 : '//[1-9][0-9]*' = //$1 : '//.*' \ \| \ //$1 : '//-[1-9][0-9]*' \> 3 \& //$1 : '//-[1-9][0-9]*' = //$1 : '//.*' \ } if { exit } perror $0 $1'": Invalid integer"' >/dev/null if X$3 != X0 -a ! { \ expr //$3 : '//[1-9][0-9]*' \> 2 \& //$3 : '//[1-9][0-9]*' = //$3 : '//.*' \ \| \ //$3 : '//-[1-9][0-9]*' \> 3 \& //$3 : '//-[1-9][0-9]*' = //$3 : '//.*' \ } if { exit } perror $0 $3'": Invalid integer"' >/dev/null if X$2 = X-eq if { exit } expr $1 = $3 >/dev/null if X$2 = X-ne if { exit } expr $1 != $3 >/dev/null if X$2 = X-gt if { exit } expr $1 \> $3 >/dev/null if X$2 = X-ge if { exit } expr $1 \>= $3 >/dev/null if X$2 = X-lt if { exit } expr $1 \< $3 >/dev/null if X$2 = X-le if { exit } expr $1 \<= $3 >/dev/null perror $0 $2'": Unknown operator"'