mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix: always set arg0 to lua scripts
Sets script's basename when no extra arguments are given
(cherry picked from commit bb9ee80a39
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
04f6463ee2
commit
38af92ce39
@@ -1358,7 +1358,7 @@ static void command_line_scan(mparm_T *parmp)
|
|||||||
}
|
}
|
||||||
parmp->luaf = argv[0];
|
parmp->luaf = argv[0];
|
||||||
argc--;
|
argc--;
|
||||||
if (argc > 0) { // Lua args after "-l <file>".
|
if (argc >= 0) { // Lua args after "-l <file>".
|
||||||
parmp->lua_arg0 = parmp->argc - argc;
|
parmp->lua_arg0 = parmp->argc - argc;
|
||||||
argc = 0;
|
argc = 0;
|
||||||
}
|
}
|
||||||
|
@@ -148,6 +148,18 @@ describe('startup', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets _G.arg', function()
|
it('sets _G.arg', function()
|
||||||
|
-- nvim -l foo.lua
|
||||||
|
assert_l_out([[
|
||||||
|
bufs:
|
||||||
|
nvim args: 3
|
||||||
|
lua args: {
|
||||||
|
[0] = "test/functional/fixtures/startup.lua"
|
||||||
|
}]],
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
eq(0, eval('v:shell_error'))
|
||||||
|
|
||||||
-- nvim -l foo.lua [args]
|
-- nvim -l foo.lua [args]
|
||||||
assert_l_out([[
|
assert_l_out([[
|
||||||
bufs:
|
bufs:
|
||||||
|
Reference in New Issue
Block a user