fix(upgrade): exit non-zero with clear error when download fails#659
Merged
Chemaclass merged 1 commit intomainfrom May 4, 2026
Merged
fix(upgrade): exit non-zero with clear error when download fails#659Chemaclass merged 1 commit intomainfrom
Chemaclass merged 1 commit intomainfrom
Conversation
Previously `bashunit upgrade` printed "upgraded successfully" even when the curl/wget download failed, leaving users on the old version with no indication of what went wrong. Now the command: - aborts immediately on download failure and returns a non-zero exit code - prints the URL it tried plus the underlying curl/wget stderr - guards against empty downloads (zero-byte files no longer overwrite the binary) - reports a clear error when the latest tag cannot be resolved - accepts BASHUNIT_INSTALL_DIR for testability
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
bashunit upgradereported success even when the binary download failed, leaving users on the old version without any clue what went wrong:This PR makes the command behave correctly and tells the user why it failed.
Behavior changes
curl: (6) Could not resolve host).git).BASHUNIT_INSTALL_DIRfor testability and uses an absolute target path instead ofcd-ing intosrc/.bashunit::io::download_toswitchescurlto-fsSLso HTTP errors (404/5xx) become real failures, and lets stderr through so the caller can surface it.Files
src/upgrade.sh— fixed control flow, error reporting, env-overridable install dirsrc/io.sh—curl -fsSL, stderr no longer swallowed, dependency miss messagetests/unit/upgrade_test.sh— new unit tests covering all failure pathsCHANGELOG.md— Unreleased entryTest plan
./bashunit tests/unit/upgrade_test.sh— 6 passing (download fail, error message surfacing, empty file, missing tag, success path, already-on-latest)./bashunit tests/— full suite greenmake sa(ShellCheck)make lint(EditorConfig)