Skip to content

Conversation

@laurenthuberdeau
Copy link
Collaborator

@laurenthuberdeau laurenthuberdeau commented Feb 10, 2026

Context

Why stop at POSIX shell?

This PR adds a new pnut variant: pnut-awk. AWK is a much better compilation target (local variables, built-in arrays) than the shell, making the pnut-awk.awk seed script smaller than pnut-sh.sh (4225 vs 6131 lines of code) and much faster to bootstrap (less than 5 seconds on the awk implementations I tested (gawk, nawk, mawk). AWK has similar characteristics (multiple implementation, stable, defined by a standard) as POSIX shell that makes them good starting points for reproducible builds.

I haven't played too much with it, I'm sure the current implementation uses extended AWK features. Some AWK implementations need to be invoked with --posix to make them conform to POSIX AWK.

Inspired by @cosinusoidally's cjsawk presentation :)

2 issues:
  - Some local variables in pnut-exe were called
    `next`, which is a reserved word in AWK.
  - The `_write` runtime function was implemented
    in a way that prevented null bytes from being
    written correctly.
@laurenthuberdeau laurenthuberdeau force-pushed the laurent/pnut-awk branch 5 times, most recently from 5b5b370 to 1d4a542 Compare February 11, 2026 15:23
@laurenthuberdeau laurenthuberdeau force-pushed the laurent/pnut-awk branch 7 times, most recently from ff95232 to 54a10f7 Compare February 11, 2026 16:36
@laurenthuberdeau laurenthuberdeau merged commit d0aab80 into main Feb 11, 2026
53 checks passed
@laurenthuberdeau laurenthuberdeau deleted the laurent/pnut-awk branch February 11, 2026 22:35
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