Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/bashkit/src/builtins/awk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3341,7 +3341,9 @@ impl AwkInterpreter {
} else {
// Not in range — check if start pattern matches
if self.matches_pattern(start) {
self.range_active.insert(rule_idx, true);
// If end also matches this same line, range closes immediately.
let end_matches = self.matches_pattern(end);
self.range_active.insert(rule_idx, !end_matches);
true
} else {
false
Expand Down
11 changes: 11 additions & 0 deletions crates/bashkit/tests/awk_range_pattern_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,14 @@ async fn awk_range_pattern_default_action() {
.unwrap();
assert_eq!(result.stdout, "a\nb\nc\n");
}

/// Start/end matching same record should only match that single record.
#[tokio::test]
async fn awk_range_pattern_start_end_same_line() {
let mut bash = Bash::new();
let result = bash
.exec(r#"printf "a\nb\na\nc\n" | awk '/a/,/a/{print}'"#)
.await
.unwrap();
assert_eq!(result.stdout, "a\na\n");
}
Loading