aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-01-02 15:34:14 +0100
committerJustin M. Keyes <justinkz@gmail.com>2023-01-05 17:10:02 +0100
commitadef308a5925a3b967af3bd7c598074e5b6cae18 (patch)
tree10bb0dc4b3801eb53b56023542283c20aff7e967 /src/nvim/main.c
parent45549f031ee52a01601c33acc411f3111cfc4e95 (diff)
downloadrneovim-adef308a5925a3b967af3bd7c598074e5b6cae18.tar.gz
rneovim-adef308a5925a3b967af3bd7c598074e5b6cae18.tar.bz2
rneovim-adef308a5925a3b967af3bd7c598074e5b6cae18.zip
feat(lua): exit 1 on Lua "-l" script error
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 908395655f..616cf1b4b6 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -608,8 +608,9 @@ int main(int argc, char **argv)
}
if (params.luaf != NULL) {
- nlua_exec_file(params.luaf);
- // return 0;
+ bool lua_ok = nlua_exec_file(params.luaf);
+ TIME_MSG("executing Lua -l script");
+ getout(lua_ok ? 0 : 1);
}
TIME_MSG("before starting main loop");
@@ -659,9 +660,8 @@ void getout(int exitval)
{
exiting = true;
- // When running in Ex mode an error causes us to exit with a non-zero exit
- // code. POSIX requires this, although it's not 100% clear from the
- // standard.
+ // On error during Ex mode, exit with a non-zero code.
+ // POSIX requires this, although it's not 100% clear from the standard.
if (exmode_active) {
exitval += ex_exitval;
}
@@ -752,6 +752,7 @@ void getout(int exitval)
if (did_emsg) {
// give the user a chance to read the (error) message
no_wait_return = false;
+ // TODO(justinmk): this may call getout(0), clobbering exitval...
wait_return(false);
}
@@ -775,10 +776,9 @@ void getout(int exitval)
os_exit(exitval);
}
-/// Preserve files and exit.
-/// @note IObuff must contain a message.
-/// @note This may be called from deadly_signal() in a signal handler, avoid
-/// unsafe functions, such as allocating memory.
+/// Preserve files, print contents of `IObuff`, and exit 1.
+///
+/// May be called from deadly_signal().
void preserve_exit(void)
FUNC_ATTR_NORETURN
{
@@ -1309,6 +1309,7 @@ static void command_line_scan(mparm_T *parmp)
break;
case 'l': // "-l" Lua script: args after "-l".
+ headless_mode = true;
silent_mode = true;
p_verbose = 1;
parmp->no_swap_file = true;
@@ -1403,8 +1404,8 @@ scripterror:
}
}
- if (embedded_mode && silent_mode) {
- mainerr(_("--embed conflicts with -es/-Es"), NULL);
+ if (embedded_mode && (silent_mode || parmp->luaf)) {
+ mainerr(_("--embed conflicts with -es/-Es/-l"), NULL);
}
// If there is a "+123" or "-c" command, set v:swapcommand to the first one.