Skip to content

fix: _vlog returns 0 when verbose=false (regression in install rc)#13

Merged
Chemaclass merged 1 commit into
mainfrom
hotfix/vlog-rc
May 3, 2026
Merged

fix: _vlog returns 0 when verbose=false (regression in install rc)#13
Chemaclass merged 1 commit into
mainfrom
hotfix/vlog-rc

Conversation

@Chemaclass

Copy link
Copy Markdown
Owner

Summary

Senior-QA acceptance run against 0.4.1 (with the README quick-start layout) caught a deeper bug than the clean/doctor self-exclusion fix:

`bashdep::_vlog` ended with the chain `bashdep::is_verbose && bashdep::_log "$@"`. When verbose is off (the default), `is_verbose` returns 1, the chain short-circuits with rc=1, and that becomes the function's exit code. `_vlog` is the last statement of `bashdep::download_url` (` lockfile: $lock_file` line, added with the verbose-mode commit), so `download_url` returned 1 on every successful download.

`bashdep::install` then counted each successful install as a failure:

```bash
bashdep::download_url ... || failures=$((failures + 1))
```

So `install` returned the number of "failures" (= number of installed deps) and `install_from` propagated it. Real-world impact:

```bash
source lib/bashdep
bashdep::install_from .bashdep || exit $? # exits 1 on a perfectly successful install
```

Why unit tests missed it

No test asserted `download_url` returns 0 on a real successful download:

  • `test_bashdep_install_returns_zero_when_all_succeed` mocks both `setup_directory` and `download_url` to `return 0`, bypassing the real path.
  • Snapshot tests check stdout, not the function's rc.
  • `test_bashdep_download_url_writes_lockfile_entry` checks file state, not rc.

The bug only fired when verbose was off (default) AND a real download path ran end-to-end. Mocked download_url tests never exercised `_vlog`.

Fix

```bash
function bashdep::_vlog() {
if bashdep::is_verbose; then bashdep::_log "$@"; fi
return 0
}
```

Always return 0 — "not verbose" is a normal state, not a failure.

New tests (7)

  • `download_url` returns 0 on success (default path)
  • `download_url` returns 0 with verbose=false
  • `download_url` returns 0 with verbose=true
  • `install` returns 0 after a real download (not mocked)
  • `install_from` returns 0 after a real download
  • `_vlog` returns 0 with verbose=false
  • `_vlog` returns 0 with verbose=true

Test plan

  • `make test` (115 tests, 170 assertions)
  • `make sa`
  • `make lint`
  • Reproduced the bug with `bashdep::install_from .bashdep || exit $?` against the published 0.4.1; confirmed fixed on this branch.
  • Cut 0.4.2 after merge

The 'is_verbose && _log' chain short-circuits with rc=1 when verbose
is off. _vlog was the last statement in download_url, so the entire
function returned 1 on a successful download. install() then counted
it as a failure, so install_from also returned non-zero on every
real install when verbose=false (the default).

Unit tests didn't catch this: no test asserted download_url returns 0
on a real successful download (they were either snapshot-based, mock
the curl call, or only check filesystem state).

Fix:
- _vlog now uses an if-block and explicit 'return 0' at the end.
- 7 new tests assert non-zero RC on every relevant path:
  download_url returns 0 on success (default + verbose-on + verbose-off
  forms), install returns 0, install_from returns 0, _vlog returns 0
  in both modes.
@Chemaclass Chemaclass self-assigned this May 3, 2026
@Chemaclass Chemaclass added the bug Something isn't working label May 3, 2026
@Chemaclass Chemaclass merged commit 80111c6 into main May 3, 2026
5 checks passed
@Chemaclass Chemaclass deleted the hotfix/vlog-rc branch May 3, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant