File tree 3 files changed +11
-1
lines changed
3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ New library features
69
69
* ` @testset foo() ` can now be used to create a test set from a given function. The name of the test set
70
70
is the name of the called function. The called function can contain ` @test ` and other ` @testset `
71
71
definitions, including to other function calls, while recording all intermediate test results. ([ #42518 ] )
72
+ * Keys with value ` nothing ` are now removed from the environment in ` addenv ` ([ #43271 ] ).
72
73
73
74
Standard library changes
74
75
------------------------
Original file line number Diff line number Diff line change @@ -256,6 +256,7 @@ setenv(cmd::Cmd; dir="") = Cmd(cmd; dir=dir)
256
256
Merge new environment mappings into the given [`Cmd`](@ref) object, returning a new `Cmd` object.
257
257
Duplicate keys are replaced. If `command` does not contain any environment values set already,
258
258
it inherits the current environment at time of `addenv()` call if `inherit` is `true`.
259
+ Keys with value `nothing` are deleted from the env.
259
260
260
261
See also [`Cmd`](@ref), [`setenv`](@ref), [`ENV`](@ref).
261
262
@@ -274,7 +275,11 @@ function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
274
275
end
275
276
end
276
277
for (k, v) in env
277
- new_env[string (k):: String ] = string (v):: String
278
+ if v === nothing
279
+ delete! (new_env, string (k):: String )
280
+ else
281
+ new_env[string (k):: String ] = string (v):: String
282
+ end
278
283
end
279
284
return setenv (cmd, new_env)
280
285
end
Original file line number Diff line number Diff line change 817
817
cmd2 = addenv (cmd, " FOO" => " foo2" , " BAR" => " bar" ; inherit= true )
818
818
@test strip (String (read (cmd2))) == " foo2 bar"
819
819
end
820
+ # Keys with value === nothing are deleted
821
+ cmd = Cmd (` $shcmd -c "echo \$ FOO \$ BAR"` , env= Dict (" FOO" => " foo" , " BAR" => " bar" ))
822
+ cmd2 = addenv (cmd, " FOO" => nothing )
823
+ @test strip (String (read (cmd2))) == " bar"
820
824
end
821
825
822
826
You can’t perform that action at this time.
0 commit comments