Skip to content

Commit 9a431f3

Browse files
authored
Fix env handling in Cmd (#36039)
Matches behaviour in docs, adds test, fixes #32454.
1 parent fb9be71 commit 9a431f3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

base/cmd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ byteenv(env::AbstractArray{<:AbstractString}) =
223223
byteenv(env::AbstractDict) =
224224
String[cstr(string(k)*"="*string(v)) for (k,v) in env]
225225
byteenv(env::Nothing) = nothing
226-
byteenv(env::Union{AbstractVector{Pair{T}}, Tuple{Vararg{Pair{T}}}}) where {T<:AbstractString} =
226+
byteenv(env::Union{AbstractVector{Pair{T,V}}, Tuple{Vararg{Pair{T,V}}}}) where {T<:AbstractString,V} =
227227
String[cstr(k*"="*string(v)) for (k,v) in env]
228228

229229
"""

test/ambiguous.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ end
312312
pop!(need_to_handle_undef_sparam, first(methods(Base.same_names)))
313313
@test_broken need_to_handle_undef_sparam == Set()
314314
pop!(need_to_handle_undef_sparam, which(Base._cat, Tuple{Any, AbstractArray}))
315-
pop!(need_to_handle_undef_sparam, which(Base.byteenv, (Union{AbstractArray{Pair{T}, 1}, Tuple{Vararg{Pair{T}}}} where T<:AbstractString,)))
315+
pop!(need_to_handle_undef_sparam, which(Base.byteenv, (Union{AbstractArray{Pair{T,V}, 1}, Tuple{Vararg{Pair{T,V}}}} where {T<:AbstractString,V},)))
316316
pop!(need_to_handle_undef_sparam, which(Base._cat, (Any, SparseArrays._TypedDenseConcatGroup{T} where T)))
317317
pop!(need_to_handle_undef_sparam, which(Base.float, Tuple{AbstractArray{Union{Missing, T},N} where {T, N}}))
318318
pop!(need_to_handle_undef_sparam, which(Base.zero, Tuple{Type{Union{Missing, T}} where T}))

test/spawn.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ end
456456
@test Set([``, echocmd]) != Set([``, ``])
457457
@test Set([echocmd, ``, ``, echocmd]) == Set([echocmd, ``])
458458

459+
# env handling (#32454)
460+
@test Cmd(`foo`, env=Dict("A"=>true)).env == ["A=true"]
461+
@test Cmd(`foo`, env=["A=true"]).env == ["A=true"]
462+
@test Cmd(`foo`, env=("A"=>true,)).env == ["A=true"]
463+
@test Cmd(`foo`, env=["A"=>true]).env == ["A=true"]
464+
@test Cmd(`foo`, env=nothing).env == nothing
465+
459466
# test for interpolation of Cmd
460467
let c = setenv(`x`, "A"=>true)
461468
@test (`$c a`).env == String["A=true"]

0 commit comments

Comments
 (0)