#!/usr/bin/env bash # lib_int.sh - the integer rule for knobs (Issue #26), on its own so scripts # that run without lib.sh (diff_collect.sh and loop_lock.sh, which the Python # runner and the tests source alone) read their knobs the same way. lib.sh # sources it. Sourcing it defines the functions and the path they run. # # Issue #17 item 4: the rule itself is lib_py/ints.py, which the loop runner # imports too (runner.py::_positive_int); these functions only call it. # They run `python3` from PATH (this file has no $PY when sourced alone): # without one, mam_int and mam_int_knob print nothing (rc 127). _MAM_INTS_PY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib_py/ints.py" # mam_int # # Blanks around, digits only, read as DECIMAL, min <= n <= 999999999 (see # lib_py/ints.py). Prints n and returns 0, or returns 1. mam_int() { python3 -I "$_MAM_INTS_PY" int "${1-}" "$2" } # mam_int_knob # # The value of $ENV_NAME through mam_int; unset or empty gives , an # invalid value gives with a warning on stderr. mam_int_knob() { python3 -I "$_MAM_INTS_PY" knob "$1" "${!1-}" "$2" "$3" }