mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 11:18:24 +00:00
All three were in code paths the original tests happened to miss. 1. A .txt.gz mapping passed positionally was rejected with "unexpected argument" — the documented way to use a downloaded release asset. The detection used `gunzip -c "$f" | head -c 200 | grep -q '^# compiler'`; `grep -q` exits at the first match, gunzip takes SIGPIPE, and `set -o pipefail` then reports the whole pipeline as failed. So a real mapping was classified as a report, and the actual report became the stray argument. Now reads the header into a variable and pattern-matches the string, with no pipeline status to misread. (The plain .txt form worked only by luck: grep consumed all 200 bytes before matching, so nothing got SIGPIPE.) 2. Every run leaked its temp directory. `exec java ...` replaces the shell, so the EXIT trap never fired — confirmed by finding five /tmp/tmp.* dirs left over from testing. Dropped the exec. 3. Reading `# compiler_version` streamed all ~500 MB of the mapping to find a line in the first hundred bytes (0.486s vs 0.003s), and left the pipeline's status at head's SIGPIPE — surviving only because sed block-buffers. Both header fields now come from one 4 KiB read. Also: cache the expanded copy under a key derived from the source path, so a hand-gzipped playRelease and fdroidRelease mapping (both "mapping.txt.gz") cannot collide; report the mapping name the user actually typed in the mismatch error rather than the cache path; and document that the cache grows by ~500 MB per release retraced. Regression matrix, all passing: positional .txt, positional .txt.gz, auto from file, auto from stdin, wrong map-id refused (exit 2), --force override, branch build rejected, missing release asset reported, --help, and zero leaked temp dirs across the run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DEoxktEZyTrAS33vVZBiwm