Skip to content

fix(builtins): read builtin now respects custom IFS for field splitting#1024

Merged
chaliy merged 2 commits intomainfrom
fix/issue-968-read-ifs-splitting
Apr 2, 2026
Merged

fix(builtins): read builtin now respects custom IFS for field splitting#1024
chaliy merged 2 commits intomainfrom
fix/issue-968-read-ifs-splitting

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Fixed read builtin to check shell variables for IFS (not just env variables)
  • Fixed last-variable join to use IFS delimiter instead of hardcoded space

Why

IFS="," sets a shell variable, but read only checked ctx.env (exported env). This caused IFS=","; read -r a b c <<< "1,2,3" to put the entire input into a.

Tests

  • Added unit tests: read_ifs_from_shell_variables, read_ifs_from_shell_variables_array
  • Fixed read_custom_ifs to expect correct IFS-delimited join (bar:baz not bar baz)
  • Added spec tests: read_custom_ifs_comma, read_custom_ifs_colon
  • 100% bash comparison match (1699/1699)

Closes #968

chaliy added 2 commits April 2, 2026 21:37
The read builtin was only checking env variables for IFS, missing
shell variables set via IFS=",". Now checks shell variables first,
then env. Also fixes the last-variable join to use the IFS delimiter
instead of hardcoded space.

Closes #968
@chaliy chaliy merged commit af74d2d into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-968-read-ifs-splitting branch April 2, 2026 22:01
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.

read builtin ignores custom IFS for field splitting

1 participant