Skip to content

[BUG] VAR=x func ignores the prefix assignment when the command is a shell function #361

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 @ dbb6189 (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 'greet() { echo "hello ${NAME-nobody}"; }; NAME=world greet; echo "after: ${NAME-unset}"'
strands-shell -c 'f() { env | grep "^LC_ALL=" || echo none; }; LC_ALL=C f'

Expected Behavior

As in bash 5.2.15:

hello world
after: unset
LC_ALL=C

The function body, and the commands it runs, see the assignment for that one call.

Actual Behavior

hello nobody
after: unset
none

The assignment is dropped. No error is printed.

Additional Context

Same family as #308, which covers builtins. #353 fixes regular builtins at the single-command builtin dispatch in src/exec.rs and doesn't change function calls, so this is the same on main and on that PR's head (a11b2bf).

Found while reviewing #353.

Possible Solution

Apply the call's prefix assignments for the duration of the function, exported, then restore the previous values, as #353 does for regular builtins.

Related Issues

#308, #353

Activity

  1. added
    bug
    on Nov 21, 2026
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

    bug

    Type

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions