fix(arcup): accept checksum files without a trailing newline - #262
fix(arcup): accept checksum files without a trailing newline#262devorun wants to merge 1 commit into
Conversation
verify_checksum_file used `if ! read -r ... < file` to detect an empty checksum file, but `read` returns non-zero when the final line has no trailing newline even though it still populates the variables. A valid `.sha256` file whose last line lacks a trailing newline was therefore rejected as "Checksum file is empty", aborting an otherwise-good install. Check the parsed hash instead of read's exit status, and add a regression test for the no-trailing-newline case. Bump the installer version per the in-file convention.
|
I executed your reproduction before commenting — the bug is real and your diagnosis of $ printf 'abc file' > ck; if ! read -r a b < ck; then echo "read FAILED, a=[$a] b=[$b]"; fi
read FAILED, a=[abc] b=[file]Non-zero exit, variables fully populated — the classic trap. That said, this is a duplicate of #243 (opened 2026-08-08, five days before this PR), down to fine detail: same title, same Credit where due: you caught something #243 missed. The in-file convention says to bump If you're looking for open ground in the same area: the arcup shellcheck CI gap (#247) and installer self-update verification (#223) threads both have adjacent unclaimed work, and #59's forwarder investigation could use more operators running the idle-gap repro described in PR #261. Happy to point you at specifics if any of those interest you. |
Summary
arcup'sverify_checksum_filerejects a valid.sha256file whose final line has no trailing newline, aborting an otherwise-successful install witherror: Checksum file is empty.Root cause
Emptiness was inferred from
read's exit status:readreturns non-zero when it reaches EOF without seeing the line delimiter — i.e. when the last line has no trailing newline — even though it has already populated the variables. So a one-line checksum file with no trailing\n(valid, and what some tooling emits) wrongly takes the "empty" branch.Reproduction
Sourcing the script with
ARCUP_SKIP_MAIN=1and callingverify_checksum_fileagainst a valid checksum file written without a trailing newline:Fix
Check the parsed hash rather than
read's exit status:A genuinely empty file still errors (the variable is empty), and the existing
^[0-9A-Fa-f]{64}$check still guards malformed content.Tests
Adds
checksum file without trailing newline passestotest_arcup.sh— the existing checksum tests only wrote newline-terminated files, so this path was uncovered. The rest of the suite is unchanged and passes. The installer version is bumped per the in-file convention.