🐛 fix: make precompact-transcript-backup.sh work on stock macOS bash 3.2#3
Merged
Conversation
409bd8c to
c4c40cf
Compare
ebedd72 to
7c0af37
Compare
macOS ships /bin/bash 3.2 by default and 3.2 does not have the mapfile builtin. precompact-transcript-backup.sh starts with `trap 'exit 0' ERR` for fail-open behavior, which silently swallowed the `mapfile: command not found` failure. The visible symptom was that ~/.claude/backups/transcripts/ grew without bound because the rotation step never actually ran. Rewrite the rotation as a POSIX `find | sort | tail | while IFS= read -r` loop so it behaves identically on bash 3 / 4 / 5. Also introduce a version bump policy in AGENTS.md (adapted from reviewable-html-workbench) and bump the plugin version 1.0.0 → 1.0.1 per that policy. Fixes #2 Reported and diagnosed by @fuuuuuuma. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
7c0af37 to
8fc7df9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hooks/precompact-transcript-backup.shusedmapfilefor the rotation step.mapfileis a bash 4+ builtin, and macOS ships/bin/bash3.2 by default. On a stock Mac the rotation failed every time withmapfile: command not found, and because the script starts withtrap 'exit 0' ERR(correct for fail-open behavior) the error was completely silent — the visible symptom was~/.claude/backups/transcripts/growing without bound.Replaced the
mapfile+ array with a POSIX-compliantfind | sort | tail | while IFS= read -rloop that behaves identically on bash 3 / 4 / 5.This PR also introduces a
Version bump policysection inAGENTS.md(adapted from the reviewable-html-workbench convention) and bumps the plugin version 1.0.0 → 1.0.1 per that policy (patch, because this is a bug fix). The policy documents the three version slots that.github/workflows/test.ymlalready enforces to be equal.Fixes #2
Changes
hooks/precompact-transcript-backup.sh:mapfile -t OLD_BACKUPS < <(...)→find ... | ... | while IFS= read -r old; do rm -f ...; doneAGENTS.md: newVersion bump policysection — semver-based bump table, keeps the three version slots (.claude-plugin/plugin.jsonversion,.claude-plugin/marketplace.jsonmetadata.version, and.claude-plugin/marketplace.jsonplugins[0].version) in sync as required by the CICheck version consistencystep.claude-plugin/plugin.json,.claude-plugin/marketplace.json(bothmetadata.versionandplugins[0].version):1.0.0→1.0.1Test plan
Verified on macOS:
/bin/bash(3.2.57): seeded 25 backups for the target session + 3 backups for another session, ran the hook, confirmed the target session was pruned to 20, the other session was untouched, exit=0, nomapfile: command not foundbash(5.3.12): same setup, same result (25→20, other session unchanged, exit=0) — no regression on bash 4+mapfile,readarray,declare -A,${var^^},${var,,}) — none found in the remaining hooks/skillsCheck version consistencylogic locally — all three slots equal 1.0.1Credits
Reported and diagnosed with a working local fix by @fuuuuuuma in #2. Thanks for the detailed reproduction and root-cause analysis.
🤖 Generated with Claude Code