{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/14249","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/14249/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/14249/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/14249/events","html_url":"https://github.com/JuliaLang/julia/issues/14249","id":120134971,"number":14249,"title":"setenv() and modifying environment","user":{"login":"nalimilan","id":1120448,"avatar_url":"https://avatars.githubusercontent.com/u/1120448?v=3","gravatar_id":"","url":"https://api.github.com/users/nalimilan","html_url":"https://github.com/nalimilan","followers_url":"https://api.github.com/users/nalimilan/followers","following_url":"https://api.github.com/users/nalimilan/following{/other_user}","gists_url":"https://api.github.com/users/nalimilan/gists{/gist_id}","starred_url":"https://api.github.com/users/nalimilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nalimilan/subscriptions","organizations_url":"https://api.github.com/users/nalimilan/orgs","repos_url":"https://api.github.com/users/nalimilan/repos","events_url":"https://api.github.com/users/nalimilan/events{/privacy}","received_events_url":"https://api.github.com/users/nalimilan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-03T10:09:35Z","updated_at":"2015-12-03T16:25:46Z","closed_at":null,"body":"It is quite common to need setting one particular environment variable when running a command,notably `LC_ALL=C` to parse reliably the output (e.g. https://github.com/JuliaLang/BinDeps.jl/issues/188). When looking for the most straightforward way of doing this, one finds `setenv`, and is thus tempted to write ``run(setenv(`mycmd`, \"LC_ALL\"=>\"C\"))``.\r\n\r\nAs the docs clearly say, this runs the command in a completely clean environment. But is this what is most commonly needed? In many cases, one would better preserve `PATH` to find commands in non-standard directories. Code failing to do so will work fine in most setups, but fails on some others, which is always painful for users.\r\n\r\nSo I wonder whether there should be another one-liner to run a command in a modified environment, so that people are not tempted to use `setenv` because that's the most obvious solution."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/161704203","html_url":"https://github.com/JuliaLang/julia/issues/14249#issuecomment-161704203","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/14249","id":161704203,"user":{"login":"StefanKarpinski","id":153596,"avatar_url":"https://avatars.githubusercontent.com/u/153596?v=3","gravatar_id":"","url":"https://api.github.com/users/StefanKarpinski","html_url":"https://github.com/StefanKarpinski","followers_url":"https://api.github.com/users/StefanKarpinski/followers","following_url":"https://api.github.com/users/StefanKarpinski/following{/other_user}","gists_url":"https://api.github.com/users/StefanKarpinski/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanKarpinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanKarpinski/subscriptions","organizations_url":"https://api.github.com/users/StefanKarpinski/orgs","repos_url":"https://api.github.com/users/StefanKarpinski/repos","events_url":"https://api.github.com/users/StefanKarpinski/events{/privacy}","received_events_url":"https://api.github.com/users/StefanKarpinski/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T16:25:46Z","updated_at":"2015-12-03T16:25:46Z","body":"One option: a keyword arg for `setenv` indicating whether it starts from a clean slate or not, i.e.\r\n\r\n```jl\r\nsetenv(`mycmd`, \"LC_ALL\" => \"C\", clean = true)  # `mycmd` with only LC_ALL in env\r\nsetenv(`mycmd`, \"LC_ALL\" => \"C\", clean = false) # `mycmd` with inherited env + LC_ALL=C\r\n```\r\n\r\nAlternate approach would be to have an `addenv` function similar to `setenv`:\r\n\r\n```jl\r\nsetenv(`mycmd`, \"LC_ALL\" => \"C\") # `mycmd` with only LC_ALL in env\r\naddenv(`mycmd`, \"LC_ALL\" => \"C\") # `mycmd` with inherited env + LC_ALL=C\r\n```\r\n"}}