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:
Mike
2023-06-26 08:44:54 +02:00
committed by github-actions[bot]
parent 04f6463ee2
commit 38af92ce39
2 changed files with 13 additions and 1 deletions

View File

@@ -1358,7 +1358,7 @@ static void command_line_scan(mparm_T *parmp)
}
parmp->luaf = argv[0];
argc--;
if (argc > 0) { // Lua args after "-l <file>".
if (argc >= 0) { // Lua args after "-l <file>".
parmp->lua_arg0 = parmp->argc - argc;
argc = 0;
}

View File

@@ -148,6 +148,18 @@ describe('startup', function()
end)
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]
assert_l_out([[
bufs: