Skip to content

[codex] Implement awk Phase 3#241

Draft
matt-dz wants to merge 5 commits intocodex/awk-phase-2from
codex/awk-phase-3
Draft

[codex] Implement awk Phase 3#241
matt-dz wants to merge 5 commits intocodex/awk-phase-2from
codex/awk-phase-3

Conversation

@matt-dz
Copy link
Copy Markdown
Collaborator

@matt-dz matt-dz commented May 7, 2026

Summary

Implements awk Phase 3 on top of codex/awk-phase-2, expanding the builtin from basic array element support into a more practical awk profile.

  • Adds associative arrays with in, delete, for (k in array), and split
  • Adds C-style for, while, break, and continue
  • Adds range patterns such as /start/,/end/
  • Adds regex FS, including -F and runtime FS = value
  • Adds field mutation, $0 rebuilds, $0 = value resplitting, and NF = value
  • Populates ENVIRON from rshell's shell-visible environment snapshot
  • Updates docs, scenario tests, Go tests, and symbol allowlists for the expanded Phase 3 surface
  • Hardens the gawk harness so triplet tests do not consume harness stdin and use bounded per-test execution

Validation

  • make fmt
  • go test ./builtins/awk ./builtins/tests/awk ./analysis
  • go test ./tests -run 'TestShellScenarios/.*/cmd/awk/'
  • RSHELL_BASH_TEST=1 go test ./tests/ -run TestShellScenariosAgainstBash -timeout 120s
  • go test ./...
  • make build
  • RSHELL_BIN=./rshell AWK_UNDER_TEST=tools/awk-harness/rshell-awk GAWK_TEST_FILTER=opasnidx tools/awk-harness/run.sh gawk
  • RSHELL_BIN=./rshell AWK_UNDER_TEST=tools/awk-harness/rshell-awk GAWK_TEST_FILTER=assignnumfield tools/awk-harness/run.sh gawk
  • RSHELL_BIN=./rshell AWK_UNDER_TEST=tools/awk-harness/rshell-awk GAWK_TEST_FILTER=splitwht tools/awk-harness/run.sh gawk

Note: the splitwht focused harness run passes the supported whitespace split case and still fails splitwht2, which uses GNU typed regexp syntax (@/.../) outside the rshell awk profile.

@matt-dz matt-dz changed the title [codex] Add awk associative array elements [codex] Implement awk Phase 3 May 7, 2026
Copy link
Copy Markdown
Collaborator Author

matt-dz commented May 7, 2026

@codex please review this PR.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95e160ef48

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread builtins/awk/runtime.go
Comment thread builtins/awk/runtime.go Outdated
Copy link
Copy Markdown
Collaborator Author

matt-dz commented May 7, 2026

@codex please review this PR again after 4d85c8b8.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d85c8b83e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread builtins/awk/eval.go
Copy link
Copy Markdown
Collaborator Author

matt-dz commented May 7, 2026

@codex please review this PR again after 8ac0c5a9.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ac0c5a909

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread builtins/awk/runtime.go
Comment thread builtins/awk/runtime.go
Copy link
Copy Markdown
Collaborator Author

matt-dz commented May 7, 2026

@codex please review this PR again after 09a78ff1.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09a78ff1bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread builtins/awk/parser.go
if !p.match(tokLParen) {
return nil, fmt.Errorf("expected ( after for")
}
p.skipSeparators()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve empty for-loop initializers

For C-style loops that intentionally omit the initializer, such as BEGIN { i=0; for (; i<3; i++) print i }, this skips the structural semicolon immediately after (, so parseOptionalForExpr parses the condition as the initializer and the parser then fails with expected ; in for loop. GNU awk accepts this form, and it is a common way to express loops with initialization done earlier; this should skip newlines only, not semicolons, before deciding whether the initializer is empty.

Useful? React with 👍 / 👎.

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.

1 participant