Skip to content

[BUG] IFS=… read ignores the prefix assignment (builtins don't see VAR=x builtin env) #308

Open

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Binding

Rust

Strands Shell Version

main @ f5c6ac4 (built from source)

Language Runtime Version

Rust 1.100.0

Operating System

Debian 12 (aarch64)

Installation Method

built from source

Steps to Reproduce

strands-shell -c 'printf "a,b\n" | { IFS=, read x y; echo "[$x][$y]"; }'
strands-shell -c 'printf "a b\n" | { IFS=, read x y; echo "[$x][$y]"; }'

Expected Behavior

As in bash 5.2: [a][b] and [a b][]. The IFS=, applies to that read only.

Actual Behavior

[a,b][] and [a][b]. read splits on the shell's IFS and ignores the prefix assignment.

Additional Context

The single-command builtin path (src/exec.rs ~3547, builtins::lookup(...)) runs the builtin without applying expanded_env, so read reads IFS from proc.env (src/builtins/read.rs). This breaks IFS= read -r line and IFS=: read a b, two very common agent idioms. Once #307 lands, it also breaks IFS= read -r -d '' x, which then drops trailing newlines or whitespace.

Found while reviewing #307.

Possible Solution

Apply the command's prefix assignments for the duration of the builtin (as bash does for non-special builtins), then restore them.

Related Issues

#307, #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions