Skip to content

fix(awk): close range when start and end match same record - #1466

Merged
chaliy merged 1 commit into
mainfrom
2026-04-24-propose-fix-for-range-pattern-issue
Apr 25, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-04-24-propose-fix-for-range-pattern-issue

Conversation

@chaliy

@chaliy chaliy commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 1de2203 Commit Preview URL Apr 25 2026, 02:43 AM

@chaliy
chaliy force-pushed the 2026-04-24-propose-fix-for-range-pattern-issue branch from f52013c to 1de2203 Compare April 25, 2026 02:42
@chaliy
chaliy merged commit b4b4b7d into main Apr 25, 2026
34 checks passed
@chaliy
chaliy deleted the 2026-04-24-propose-fix-for-range-pattern-issue branch April 25, 2026 02:52
@codecov

codecov Bot commented Apr 25, 2026

Copy link
Copy Markdown

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant