@@ -262,6 +262,15 @@ setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir=cmd.dir) =
262262 setenv (cmd, env; dir= dir)
263263setenv (cmd:: Cmd ; dir= cmd. dir) = Cmd (cmd; dir= dir)
264264
265+ # split environment entry string into before and after first `=` (key and value)
266+ function splitenv (e:: String )
267+ i = findnext (' =' , e, 2 )
268+ if i === nothing
269+ throw (ArgumentError (" malformed environment entry" ))
270+ end
271+ e[1 : prevind (e, i)], e[nextind (e, i): end ]
272+ end
273+
265274"""
266275 addenv(command::Cmd, env...; inherit::Bool = true)
267276
@@ -282,7 +291,7 @@ function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
282291 merge! (new_env, ENV )
283292 end
284293 else
285- for (k, v) in eachsplit .(cmd. env, " = " )
294+ for (k, v) in splitenv .(cmd. env)
286295 new_env[string (k):: String ] = string (v):: String
287296 end
288297 end
@@ -301,7 +310,7 @@ function addenv(cmd::Cmd, pairs::Pair{<:AbstractString}...; inherit::Bool = true
301310end
302311
303312function addenv (cmd:: Cmd , env:: Vector{<:AbstractString} ; inherit:: Bool = true )
304- return addenv (cmd, Dict (k => v for (k, v) in eachsplit .(env, " = " )); inherit)
313+ return addenv (cmd, Dict (k => v for (k, v) in splitenv .(env)); inherit)
305314end
306315
307316"""
0 commit comments