Skip to content

fix(awk): evaluate regex literals against $0 in boolean context#827

Merged
chaliy merged 1 commit intomainfrom
fix/issue-808-awk-compound-pattern
Mar 26, 2026
Merged

fix(awk): evaluate regex literals against $0 in boolean context#827
chaliy merged 1 commit intomainfrom
fix/issue-808-awk-compound-pattern

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 26, 2026

Summary

  • Fix awk compound patterns like flag && /^id:/ which were ignoring the regex
  • Add eval_expr_as_bool() method that handles AwkExpr::Regex by matching against $0
  • Applied to &&, ||, and ! operators

Test plan

  • awk_compound_pattern_and_regexflag && /^id:/ correctly filters lines
  • test_awk_gsub_with_print — regex args to gsub still work as pattern strings
  • Full test suite passes

Closes #808

Closes #808 — compound patterns like `flag && /^id:/` now correctly
evaluate the regex against $0 instead of treating it as a truthy string.

Added eval_expr_as_bool() which handles AwkExpr::Regex specially by
matching against the current line. Used in &&, ||, and ! operators.
@chaliy chaliy merged commit 45ea773 into main Mar 26, 2026
18 of 23 checks passed
@chaliy chaliy deleted the fix/issue-808-awk-compound-pattern branch March 26, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: awk compound pattern expr && /regex/ ignores the regex

1 participant