#!/bin/bash
#  math - Script math support library

set -e


# 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 variable (named by $1) such that $2 <= $1 <= $3
#  $1 - variable
#  $2 - minimum
#  $3 - maximum
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
}

View the Script Reference Index


Generated on Tue Apr 25 21:20:12 PDT 2017 by mcsh i7 v0.18.0.