Fix post-increment causing silent exit under set -e#619
Merged
Chemaclass merged 4 commits intoTypedDevs:mainfrom Apr 9, 2026
Merged
Fix post-increment causing silent exit under set -e#619Chemaclass merged 4 commits intoTypedDevs:mainfrom
Chemaclass merged 4 commits intoTypedDevs:mainfrom
Conversation
Chemaclass
reviewed
Apr 9, 2026
Member
There was a problem hiding this comment.
- Complete coverage: all standalone
((var++))outsideforloop headers are changed.state.shis correctly left alone since it already uses|| true. - Correct scope: bashunit runs with
set -euo pipefail(set in/bashunitline 2 andsrc/globals.sh), so this affects bashunit's own execution, not just user scripts. - CHANGELOG entry is accurate and references #618.
- No behavior change: only the expression return value changes, not the increment itself.
Concern: No regression test
The PR has zero tests. Given this bug causes silent failures (the { ... } > "$output_file" redirect swallows the error), a regression test would be valuable. Something like:
function test_get_executable_lines_succeeds_under_set_e() {
local result
result=$(set -e; bashunit::coverage::get_executable_lines "some_file.sh")
assert_greater_than 0 "$result"
}This would prevent future regressions if someone reintroduces ((var++)).
Add tests that run get_executable_lines, report_lcov, and str::rpad in subshells with set -e to ensure ((++var)) does not cause silent early exit when the counter starts at zero.
Chemaclass
approved these changes
Apr 9, 2026
Member
|
The failing are flaky tests not related to this changes. PR good to merge. Thanks! |
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.
Background
Related #618
LCOV and HTML coverage reports were incomplete/missing due to
((var++))post-increment operator causing early script termination underset -e.Changes
report_lcov()andgenerate_file_html()post-increment causing silent exit underset -e((var++))to((++var))for consistency (preventive)Checklist
CHANGELOG.mdto reflect the new feature or fix