Repository navigation
fix(awk): close range when start and end match same record - #1466
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 1de2203 | Commit Preview URL | Apr 25 2026, 02:43 AM |
chaliy
force-pushed
the
2026-04-24-propose-fix-for-range-pattern-issue
branch
from
April 25, 2026 02:42
f52013c to
1de2203
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
chaliy
added a commit
that referenced
this pull request
May 30, 2026
### Motivation
- Range `/start/,/end/` activated on a start match was not checking
whether the end pattern also matches the same record, causing ranges
like `/a/,/a/` to remain active and overmatch subsequent lines.
- Aim to follow awk semantics where a start and end match on the same
record should include only that record and immediately close the range.
### Description
- Update `matches_pattern_with_index()` in
`crates/bashkit/src/builtins/awk.rs` to evaluate the end pattern
immediately when the start pattern matches and store `!end_matches` as
the new `range_active` state.
- Add regression test `awk_range_pattern_start_end_same_line` in
`crates/bashkit/tests/awk_range_pattern_tests.rs` that verifies
`/a/,/a/{print}` only prints the matching record(s).
- Commit message: `fix(awk): close range when start and end match same
record`.
### Testing
- Ran `cargo test --test awk_range_pattern_tests` and all tests passed:
`8 passed; 0 failed`.
- The added regression test `awk_range_pattern_start_end_same_line`
passes under the same test run.
------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_69eaf1c5c59c832b876fade70ec8f63d)
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.
Motivation
/start/,/end/activated on a start match was not checking whether the end pattern also matches the same record, causing ranges like/a/,/a/to remain active and overmatch subsequent lines.Description
matches_pattern_with_index()incrates/bashkit/src/builtins/awk.rsto evaluate the end pattern immediately when the start pattern matches and store!end_matchesas the newrange_activestate.awk_range_pattern_start_end_same_lineincrates/bashkit/tests/awk_range_pattern_tests.rsthat verifies/a/,/a/{print}only prints the matching record(s).fix(awk): close range when start and end match same record.Testing
cargo test --test awk_range_pattern_testsand all tests passed:8 passed; 0 failed.awk_range_pattern_start_end_same_linepasses under the same test run.Codex Task