Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

canonicalize Windows environment variables to uppercase #30593

Merged
merged 6 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if Sys.iswindows()
if m === nothing
error("malformed environment entry: $env")
end
return (Pair{String,String}(m.captures[1], m.captures[2]), (pos+(len+1)*2, blk))
return (Pair{String,String}(uppercase(m.captures[1]), m.captures[2]), (pos+(len+1)*2, blk))
stevengj marked this conversation as resolved.
Show resolved Hide resolved
end
else # !windows
function iterate(::EnvDict, i=0)
Expand Down
16 changes: 16 additions & 0 deletions test/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,19 @@ end
@test ENV["testing_envdict"] == "tested"
delete!(ENV, "testing_envdict")
end

if Sys.iswindows()
@testset "windows case-insensitivity" begin
push!(ENV, "testing_envdict" => "tested")
@test haskey(ENV, "TESTING_ENVDICT")
@test ENV["TESTING_ENVDICT"] == "tested"
@test "TESTING_ENVDICT" in keys(ENV)
@test "TESTING_ENVDICT" in collect(keys(ENV))
@test "testing_envdict" ∉ collect(keys(ENV))
env = copy(ENV)
@test haskey(env, "TESTING_ENVDICT")
@test !haskey(env, "testing_envdict")
delete!(ENV, "testing_envdict")
@test !haskey(ENV, "TESTING_ENVDICT")
end
end