Skip to content

Commit

Permalink
Fix empty updates in dynamic init scripts
Browse files Browse the repository at this point in the history
opam already ensured that empty segments are never added to environment
variables with opam env, but the filter was not there for writing the
dynamic init scripts.
  • Loading branch information
dra27 committed Sep 23, 2024
1 parent dd5a6cf commit a35a1e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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
11 changes: 10 additions & 1 deletion src/state/opamEnv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,16 @@ 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 = function
| {envu_value = ""; envu_op; _} ->
envu_op = Eq
| _ -> 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

0 comments on commit a35a1e6

Please sign in to comment.