mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
fix(vim.system): env=nil passes env=nil to uv.spawn
731e616a79
made it so passing `{env = nil, clear_env = true }` would pass `{env = {}}` to `vim.uv.spawn`. However this is not what `clear_env` is (arguably) supposed to do. If `env=nil` then that implies the uses wants `vim.uv.spawn()` to use the default environment. Adding `clear_env = true` simply prevents `NVIM` (the base environment) from being added. Fixes #34730 (cherry picked from commit4eebc46930
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
2d3517012a
commit
e732cbe36c
@@ -93,6 +93,27 @@ describe('vim.system', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('can set environment with clear_env = true and env = nil', function()
|
||||
exec_lua(function()
|
||||
vim.env.TEST = 'TESTVAL'
|
||||
end)
|
||||
|
||||
-- Not passing env with clear_env should not clear the environment
|
||||
eq(
|
||||
'TESTVAL',
|
||||
system({ n.testprg('printenv-test'), 'TEST' }, { clear_env = true, text = true }).stdout
|
||||
)
|
||||
|
||||
-- Passing env = {} with clear_env should clear the environment
|
||||
eq(
|
||||
'',
|
||||
system(
|
||||
{ n.testprg('printenv-test'), 'TEST' },
|
||||
{ env = {}, clear_env = true, text = true }
|
||||
).stdout
|
||||
)
|
||||
end)
|
||||
|
||||
it('supports timeout', function()
|
||||
eq({
|
||||
code = 124,
|
||||
|
Reference in New Issue
Block a user