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

Fix empty updates in dynamic init scripts #6198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ users)
## Clean

## Env
* Don't write empty environment update segments to variables.sh (`FOO += ""` no longer adds `FOO='':"$FOO"; export FOO;`) [#6198 @dra27]

## Opamfile

Expand Down
15 changes: 14 additions & 1 deletion src/state/opamEnv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,20 @@ let write_custom_init_scripts root custom =
) custom

let write_dynamic_init_scripts st =
let updates = updates ~set_opamroot:false ~set_opamswitch:false st in
(* Empty environment updates must not be written to the scripts *)
let is_not_empty_update
: (_, OpamTypes.euok_writeable) OpamTypes.env_update -> _ = function
| {envu_value = ""; envu_op; _} ->
begin match envu_op with
| PlusEq | EqPlus | ColonEq | EqColon | EqPlusEq -> false
| Eq -> true
end
| _ -> true
in
let updates =
updates ~set_opamroot:false ~set_opamswitch:false st
|> List.filter is_not_empty_update
in
try
if OpamStateConfig.is_newer_than_self
~lock_kind:`Lock_write st.switch_global then
Expand Down
Loading