Skip to content

expand: FuncEnviron provided environment variables will not copy cross pipe #1043

Closed

Description

@zhaodiaoer

When using expand.FuncEnviron to generate runner and using this runner to run the file type Node that contains any pipe operator symbol, it will cause environment variables to not transfer across pipes and be visible for all command statements.

That's because expand.FuncEnviron does implement the Environ interface, but the Each is no-op method, so when executing runner.Subshell() to get a new runner for one side command of pipe, environment variables will not be copied as expected.

It would be helpful to add comments to the expand.FuncEnviron function. This will prevent others from troubleshooting similar problems for a long time, like I did.

Activity

  1. mvdan commented on Nov 15, 2023

    @mvdan
    Owner

    Thanks for spotting this - I agree it's a significant pitfall. I'd prefer to fix this over documenting the limitation, as it seems rather severe.

  2. mvdan commented on Nov 15, 2023

    @mvdan
    Owner

    Just pushed a fix after some tweaking - let me know if that works.

  3. added a commit that references this issue on Feb 13, 2024
    87850d3
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址