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

Feature request: when using addenv, allow "FOOBAR" => nothing to delete the FOOBAR environment variable #43562

Closed
DilumAluthge opened this issue Dec 27, 2021 · 2 comments
Labels
feature Indicates new feature / enhancement requests

Comments

@DilumAluthge
Copy link
Member

When using the withenv function, I can pass "FOOBAR" => nothing in order to delete the FOOBAR environment variable:

julia> cmd = `$(Base.julia_cmd()) -e '@info "" haskey(ENV, "FOOBAR"); @info "" get(ENV, "FOOBAR", "not found")'`;

julia> ENV["FOOBAR"] = "hello world"
"hello world"

julia> withenv() do
           run(cmd);
       end;
┌ Info:haskey(ENV, "FOOBAR") = true
┌ Info:get(ENV, "FOOBAR", "not found") = "hello world"

julia> withenv("FOOBAR" => nothing) do
           run(cmd);
       end;
┌ Info:haskey(ENV, "FOOBAR") = false
┌ Info:get(ENV, "FOOBAR", "not found") = "not found"

However, currently, I cannot use the same syntax to delete an environment variable when using the addenv function:

julia> cmd = `$(Base.julia_cmd()) -e '@info "" haskey(ENV, "FOOBAR"); @info "" get(ENV, "FOOBAR", "not found")'`;

julia> ENV["FOOBAR"] = "hello world"
"hello world"

julia> run(addenv(cmd));
┌ Info:haskey(ENV, "FOOBAR") = true
┌ Info:get(ENV, "FOOBAR", "not found") = "hello world"

julia> run(addenv(cmd, "FOOBAR" => nothing));
┌ Info:haskey(ENV, "FOOBAR") = true
┌ Info:get(ENV, "FOOBAR", "not found") = "nothing"

I think it would be nice if run(addenv(cmd, "FOOBAR" => nothing)) deleted the FOOBAR environment variable when running the command, instead of the current behavior (in which it sets the value of the FOOBAR environment variable to a string with the contents "nothing").

@DilumAluthge DilumAluthge added the feature Indicates new feature / enhancement requests label Dec 27, 2021
@DilumAluthge
Copy link
Member Author

cc: @staticfloat

@fredrikekre
Copy link
Member

#43271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

2 participants