-
Notifications
You must be signed in to change notification settings - Fork 656
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
Bash style variable expension in env var supports defaults using variables #2223
Bash style variable expension in env var supports defaults using variables #2223
Conversation
Same unrelated PR fail as in #2193 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the feature but the implicit expansion to empty string worries me. I know that bash has this behavior when not run in strict mode.
Still, I am not very keen on replicating bash bugs, especially as one like this would easily get ignored.
I am not +1/-1 because I want to see what other think about desired behavior when variable is not defined.
I personally prefer getting an error and asking user to provide a default if they want, like:
@ssbarnea Thanks for the feedback! I am open for changes and I am keen to what other have to say! My reasoning is that this behavior lays in the extend of the syntax and is expected for the endusers (Bash is default non strict). |
@decentral1se Any input on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big +1 from me, I've definitely wanted this at least a couple times. My only comment is that it might make sense to make the interpolation recursive (so you could do ${UNDEFINED:-${STILL_UNDEFINED:-hello}}
), but I've never really needed more than two levels anyway so it's probably more complex than it's worth.
@fabianvf Thanks for the opinion! I think the recursive option is a little overkill, at some point you should reconsider your approach ;) Will fix the conflicts first thing tomorrow :) |
Signed-off-by: wilmardo <info@wilmardenouden.nl>
Closes: #2250
PR Type
Expand the interpolation so expands default defined variables. Based on the implementation in bash:
When the default variable is not found it returns an empty string.
I use this to postfix the platform names so no conflicts happen, in the CI it uses a predefined Gitlab variable, for local testing it takes the user running molecule.
Changes: