#!/bin/bash
# args - Bash argument handling library
set -e
check_args() {
local tst=$1
local expect=$2
shift 2
local nargs="${#@}"
assert_usage "wrong number of arguments ($nargs $tst $expect)" \
[ ! $nargs $tst $expect ]
}
has_args() { check_args -ne "$@"; }
min_args() { check_args -lt "$@"; }
max_args() { check_args -gt "$@"; }
# arg_quote - quotes a single argument
arg_quote() {
has_args 1 "$@"
# handle existing quotes
local value=${1//\'/\'\\\'\'}
printf "'%s'" "$value"
}
Generated on Tue Apr 25 21:20:00 PDT 2017 by mcsh i7 v0.18.0.