Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zhaodiaoer opened this issue Nov 15, 2023 · 2 comments
Closed

Comments

@zhaodiaoer
Copy link

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.

@mvdan
Copy link
Owner

mvdan commented Nov 15, 2023

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.

@mvdan mvdan closed this as completed in 87850d3 Nov 15, 2023
@mvdan
Copy link
Owner

mvdan commented Nov 15, 2023

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

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

No branches or pull requests

2 participants