Skip to content

Commit 6266e64

Browse files
committed
rabbitmq_ct_helpers: Fix handling of unset env. variables in exec/2.
[Why] A variable can be set to `false` to explicitly unset it in the child process. This was ignored and converted to the string "false". [How] We special-case `false` and leave it as is.
1 parent 083889e commit 6266e64

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,10 @@ exec([Cmd | Args], Options) when is_list(Cmd) orelse is_binary(Cmd) ->
880880
Env1 = [
881881
begin
882882
Key1 = format_arg(Key),
883-
Value1 = format_arg(Value),
883+
Value1 = case Value of
884+
false -> false;
885+
_ -> format_arg(Value)
886+
end,
884887
Value2 = case is_binary(Value1) of
885888
true -> binary_to_list(Value1);
886889
false -> Value1
@@ -894,8 +897,10 @@ exec([Cmd | Args], Options) when is_list(Cmd) orelse is_binary(Cmd) ->
894897
| proplists:delete(env, PortOptions1)],
895898
Log ++ "~n~nEnvironment variables:~n" ++
896899
string:join(
897-
[rabbit_misc:format(" ~ts=~ts", [K, string:replace(V, "~", "~~", all)])
898-
|| {K, V} <- Env1],
900+
[rabbit_misc:format(
901+
" ~ts=~ts",
902+
[K, string:replace(V, "~", "~~", all)])
903+
|| {K, V} <- Env1, is_list(V) ],
899904
"~n")
900905
}
901906
end,

0 commit comments

Comments
 (0)