-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: os: ExpandEnv: Support Parameter Substitution and Expansion Notations #47187
Comments
The os library is not meant to be a bash library, and should not evolve in that direction. Although to do so might be convenient in some situations, the operations listed here, as well as their syntax, are not universal, and it would be wrong to act as though they were. The os package must remain portable in both function and behavior across multiple different systems. Also, the operations here are trivial to implement in Go in the rare cases they are needed. |
Oh, make sense! Also, I think we may need to write a "tiny" lexer to parse that bash syntax, which may overcomplicate |
If you do want to support the full shell/bash syntax, take a look at https://pkg.go.dev/mvdan.cc/sh/v3/shell#Expand. The module also contains a syntax parser. I fully agree that none of that should be in the standard library. |
This proposal has been added to the active column of the proposals project |
The drone/envsubst package gets you most of the way there. |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
Currently, os.ExpandEnv(s string) string - supports only$var and $ {var} notations:
I propose that Go also should support Parameter Substitution and Expansion notations:
*
If var is set, evaluate the expression as $var with no side-effects.#
Note that some of the above behavior of operators has changed from earlier versions of Bash.Example:
The text was updated successfully, but these errors were encountered: