- Fix bash arithmetic crash on MobaXterm/Cygwin: $(date +%s) was returning CR-tainted values landing in $(( )) operands - Mouse mode off by default; opt in via LARRY_MOUSE=1 or /mouse on - Comprehensive CR-safety sweep across lib/*.sh and larry.sh — every command-substitution result, file read, and user input that feeds an arithmetic context, case dispatcher, or path/header is now CR-stripped at the source New shared helper lib/cygwin-safe.sh defines three primitives: coerce_int VAL [DEFAULT] — for arithmetic / integer-test operands strip_cr VAL — for case patterns, regex tests, paths, headers read_clean VAR [PROMPT] — read -r wrapper that strips CR pre-assign Hardened call sites (14 files, 60+ patch points): - larry.sh: status-line date/tput, 3 y/N approvals, auth menu, API key - lib/oauth.sh: cmd_login + cmd_refresh date+%s captures - lib/nc-engine.sh: 5 y/N action prompts + find|wc arithmetic - lib/nc-msgs.sh: parse_time_ms (4 date sites) + meta-TSV time + MSG_COUNT - lib/nc-regression.sh: tr|wc count + hl7-diff ?-fallback arithmetic - lib/nc-smat-diff.sh: A_COUNT/B_COUNT/DIFFS_TOTAL - lib/nc-insert-protocol.sh: every awk-emitted line number → head/tail math - lib/journal.sh: _next_seq wc -l arithmetic - lib/lessons.sh: _next_id/_count + 2 y/N prompts - lib/hl7-sanitize.sh: cmd_count + clear-table y/N - lib/ssh-helper.sh: 4 local+remote wc -c integer compares - lib/nc-find.sh, lib/nc-table.sh, lib/nc-document.sh, larry-rollback.sh Reproduces the exact error Bryan hit: bash: ...: arithmetic syntax error: invalid arithmetic operator (error token is "") lib/cygwin-safe.sh added to MANIFEST so it auto-syncs on next launch. Co-Authored-By: Clover (Claude Opus 4.7) <noreply@anthropic.com>
4.1 KiB
Changelog
All notable changes to cloverleaf-larry / larry-anywhere are recorded here.
Versioning is loose-semver; bumps trigger the in-process self-update on every
running client via LARRY_BASE_URL + MANIFEST.
v0.7.5 — 2026-05-27
Three focused changes, one common cause: the Cygwin/MobaXterm CR-taint pattern
that crashed OAuth on Bryan's v0.7.3 work-box with the cryptic error
bash: ...: arithmetic syntax error: invalid arithmetic operator (error token is "").
-
OAuth/arithmetic CR fix.
lib/oauth.shnow routes every operand entering a bash arithmetic context (fetched_at,expires_in,now) through a dedicatedcoerce_inthelper that strips non-digits at the source. The failure mode:$(date +%s)against a Cygwin pty where Windows-nativedate.exeshadows Cygwindatecan return a CR-tainted epoch like"1779999999\r", which crashes the very next$((expires_at - now)). Diagnosis inDeliverables/2026-05-27-cloverleaf-larry-oauth-arithmetic-fix.md. -
Mouse mode is opt-in. REPL mouse handling now defaults to OFF and is enabled via
LARRY_MOUSE=1env var or/mouse onslash command. Several terminals (notably MobaXterm and stripped tmux) were swallowing the mouse ANSI sequences and printing literal^[[?1000hgarbage when v0.7.0 turned it on unconditionally. Diagnosis inDeliverables/2026-05-27-cloverleaf-larry-mouse-regression-fix.md. -
CR-safety sweep across
lib/*.shand top-level scripts. Three new primitives inlib/cygwin-safe.sh(sourced by every tool family member):coerce_int VAL [DEFAULT]— for arithmetic and integer-test operandsstrip_cr VAL— for case patterns, regex tests, paths, HTTP headersread_clean VAR [PROMPT]—read -rwrapper that strips CR pre-assign Hardened call sites:larry.sh— status-linedate +%s/tput cols, three y/N approval prompts (write_file, bash_exec, first-run auth), API-key paste, first-run auth menulib/oauth.sh—cmd_loginandcmd_refreshdate +%scaptureslib/nc-engine.sh— five y/N action prompts (stop/start/bounce, resend, route-test, testxlate, tpstest) +find ... | wc -larithmeticlib/nc-msgs.sh—parse_time_msdatecaptures (4 sites), meta-TSVtmfield,MSG_COUNTwc -llib/nc-regression.sh—tr | wc -ccount, hl7-diff?-fallback arithmeticlib/nc-smat-diff.sh—A_COUNT/B_COUNT/DIFFS_TOTALlib/nc-insert-protocol.sh— every awk-emitted line-number that feedshead -n $((N-1))/tail -n +$((N+1))arithmeticlib/journal.sh—_next_seqwc -larithmeticlib/lessons.sh—_next_id,cmd_list,cmd_countarithmetic + two y/N prompts (clear all, clear since)lib/hl7-sanitize.sh—cmd_countarithmetic + clear-table y/Nlib/ssh-helper.sh— local + remotewc -cinteger compares (4 sites)lib/nc-find.sh—wc -lcount for%dprintflib/nc-table.sh—$(date +%s)in backup-filename constructionlib/nc-document.sh— twowc -l | %dprintf siteslarry-rollback.sh— Proceed? y/N prompt
Reproduction (now exercised by
cygwin-safe.sh's in-line tests):now=$(printf '%s\r' 1779999999); echo $((now - 1)) # pre-fix: crashes now=$(coerce_int "$(printf '%s\r' 1779999999)" 0); echo $((now - 1)) # fix: 1779999998Added
lib/cygwin-safe.shtoMANIFESTso it auto-syncs to every running client on next launch.
v0.7.4 — 2026-05-27
- Drop GitHub fallback from auto-update. Single-source Gitea
(
https://git.bjnoela.com/bryan/cloverleaf-larry.git).
v0.7.3 — 2026-05-26
- Automatic PHI detection (tiered detection + blacklist contexts).
v0.7.2 — 2026-05-26
- Gitea becomes primary auto-update origin; GitHub demoted to fallback.
v0.7.1 — 2026-05-26
- Status line moves to between-turn position (post-input, pre-response).
- Status line below prompt; automatic PHI detection; session-artifact upload.
v0.7.0 — 2026-05-26
- HL7-aware tab completion + REPL mouse mode (later made opt-in in v0.7.5).