#!/bin/bash
# math - Bash Script Math Support
set -e
######
# Integer Math
# int_inc() - Increments the integer variables named by its arguments.
int_inc() {
min_args 1 "$@"
local _int
for _int in "$@"; do
local -n var=$_int
var=$(($var + 1))
done
}
# int_bind() - Binds named variable ($1), such that ``$2 <= $1 <= $3``.
# $1 - Variable name
# $2 - Minimum value
# $3 - Maximum value
int_bind() {
has_args 3 "$@"
local -n var=$1
local min=$2
local max=$3
[ $min -lt $var ] || var=$min
[ $max -gt $var ] || var=$max
}
Generated on Wed Jun 28 07:39:41 PDT 2017 by mcsh d14 v0.20.0.