Files
multi-agent-mux/.agents/skills/lib_int.sh
T
GodopuandClaude Opus 5.5 c90a0afa96 docs(issue-17): lib_int.sh runs python3 from PATH (N3)
mam_int / mam_int_knob call `python3 -I` because the file is also sourced
without lib.sh and so without $PY. The header now says so, and that without
a python3 on PATH they print nothing (rc 127). The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCGpJXhSZasJLU38ksDghe
2026-10-08 08:12:44 +09:00

28 lines
1.1 KiB
Bash

#!/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 <value> <min>
#
# 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 <ENV_NAME> <default> <min>
#
# The value of $ENV_NAME through mam_int; unset or empty gives <default>, an
# invalid value gives <default> with a warning on stderr.
mam_int_knob() {
python3 -I "$_MAM_INTS_PY" knob "$1" "${!1-}" "$2" "$3"
}