Skip to content

Ensure split() handles string " " differently from regex / /#278

Merged
benhoyt merged 3 commits into
masterfrom
fix-split-single-space
Apr 11, 2026
Merged

Ensure split() handles string " " differently from regex / /#278
benhoyt merged 3 commits into
masterfrom
fix-split-single-space

Conversation

@benhoyt
Copy link
Copy Markdown
Owner

@benhoyt benhoyt commented Apr 6, 2026

  • split(in, a, " ") should split like strings.Fields(), trimming whitespace
  • split(in, a, / /) should split on a single space

In general, when /.../ slashes are used, the content is explictly a regex and should be treated as such.

This is as per the other AWKs. (The POSIX spec is a little unclear on this point, but seems to hint at it.)

- split(in, a, " ") should split like strings.Fields(), trimming
  whitespace
- split(in, a, / /) should split on a single space

This is as per the other AWKs. (The POSIX spec is a little unclear on
this point, but seems to hint at it.)
@benhoyt
Copy link
Copy Markdown
Owner Author

benhoyt commented Apr 6, 2026

Hmmm, behaviour related to this was changed in Gawk 5.3.2 as well. Might need to tweak this. See https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?h=gawk-5.3.2&id=12e260e3bfedd72f8a2d5f3570e4ff15ec7f006c

@benhoyt benhoyt merged commit b061bba into master Apr 11, 2026
9 checks passed
@benhoyt benhoyt deleted the fix-split-single-space branch April 11, 2026 00:27
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