Repository navigation
feat(awk): rewrite awk to match gawk 5.2 - #2583
Merged
Merged
Conversation
New lexer, parser, async evaluator and I/O layer targeting gawk, Debian's awk. Commands (system, print | cmd, cmd | getline) run in the sandbox shell through an execution-plan driver. ERE translation adds POSIX leftmost-longest matching. Number output, printf, rand, substr, getline and diagnostics follow gawk. All resource caps are kept; split and record splitting now stop at the memory cap before building their vectors. Debian-oracle awk score: 51.5% -> 93.8% of 260 cases. Claude-Session: https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 8bbe6de | Commit Preview URL Branch Preview URL |
Oct 07 2026, 06:55 PM |
…-1mku65 # Conflicts: # knowledge/foundations/builtins.md # knowledge/log.md
…-1mku65 # Conflicts: # knowledge/log.md
This was referenced Oct 7, 2026
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.
Requested by Михайло · project thread
What changed
awk(andgawk/mawk/nawk) is rewritten to behave like gawk 5.2, which is Debian'sawk.gensub,asort/asorti,patsplit,strftime/mktime/systime,BEGINFILE/ENDFILE,switch, arrays of arrays,PROCINFO["sorted_in"],FIELDWIDTHS/FPAT,IGNORECASE, regexRSwithRT,typeofand the bit functions.system(),print | cmdandcmd | getlinerun in the sandbox shell through an execution-plan driver, the same mechanismmakeuses. Output stays in order.printf(%c,%i,*,%n$, inf/nan),rand()'s sequence, regex matching (POSIX leftmost-longest) andsubstr/getline/typeofedge cases all follow gawk.awk: cmd. line:N:with a caret and exit 1. Runtime errors print locatedfatal:messages and exit 2. Usage goes to stderr with exit 1.-f(repeatable),-e/--source,--,-F t,-vwith escapes,--csv, and gawk's no-op flags are accepted.split()and record splitting now stop at the memory cap instead of first building a huge vector.Why
pseudo-linus runs a Debian-oracle bench, and on it bashkit's awk matched only 51.5% of 260 cases. It was the weakest common text tool there. The old design could not reach gawk: it was a sync evaluator that hopped threads for I/O, arrays were stored as
"name[key]"variables, function locals were broken, and commands were unsupported.Before / After
Debian-oracle differential run (gawk 5.2.1 goldens, 260 awk cases):
mawkby name and expect its own dialect (-Woptions, messages,substr, division by zero; L-AWK-004).for (k in a)order, which follows gawk's hash tables (L-AWK-001). That is a follow-up.system, pipes,cmd | getline, syntax errors andsubstr.Risk
--csvno longer setsOFSto,.substr(s, 0, n)keepsncharacters. RedirectedgetlineleavesNRalone.-0prints0. Non-ASCII identifiers are now a syntax error.Builtin::execute. Direct calls have no shell, so commands report 127 with a notice (L-AWK-003).Checklist
https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj