-
Notifications
You must be signed in to change notification settings - Fork 365
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
Two (more) environment fixes #5837
Conversation
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.
The manual might need to be updated. In particular, it says:
FOO += ""
,FOO := ""
, etc. are all ignored - i.e. opam never adds empty segments to an existing variable.
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.
It is missing a test for the case add an empty string to an undefined variable. Nothing changes in the environment as the variable is not defined beforehand.
diff --git a/tests/reftests/env.test b/tests/reftests/env.test
index 0a8a7a210..781341de3 100644
--- a/tests/reftests/env.test
+++ b/tests/reftests/env.test
@@ -80,6 +80,7 @@ setenv: [
[ NV_VARS3 := "" ]
[ NV_VARS3 := "foo" ]
[ NV_VARS4 = "" ]
+ [ NV_VARS5 += "" ] # undefined
]
flags: compiler
### opam switch create emptyvar nv
An update of the documentation to be more precise, and lgtm!
I think the manual’s correct, isn’t it? The issue was that opam wasn’t previously doing what it was supposed to (by any definition of |
If FOO=bar in the environment, the update FOO += "" will cause FOO to cease to be defined in the environment.
When applying environment updates, opam ensures that the final value only appears once in the list. This is done by looking at the keys in the list of updates and filtering out the values in the environment itself (the computation of the updates already takes into account existing values). The only problem is that FOO += "" will be filtered when the updates are applied, resulting in no value for FOO in the final environment _unless_ there was another update to it in the list. The fix is simply apply the updates first, and then compute the filtered keys afterwards.
Logical statement became accidentally inverted.
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.
thanks!
Thanks |
Two fixes here, both relatively subtle:
FOO=bar
, the updateFOO += ""
would cause opam to execute withoutFOO
in the environment