diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:17:48 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:17:48 +0200 |
commit | b09f4483416c54c1782824633dfabaf2ec0265b6 (patch) | |
tree | 304bc82642862525ae680c7fbaa249663b10ad57 /Src/init.c | |
parent | 12eb3e5356f2fc3351eed58ef1cef1b8fb83b504 (diff) | |
parent | 6e55c920503071e917619b8cb1a188cd35d772db (diff) | |
download | zsh-b09f4483416c54c1782824633dfabaf2ec0265b6.tar.gz zsh-b09f4483416c54c1782824633dfabaf2ec0265b6.zip |
New upstream version 5.8.1.2-test
Diffstat (limited to 'Src/init.c')
-rw-r--r-- | Src/init.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/Src/init.c b/Src/init.c index 99ccc16cf..871d46b12 100644 --- a/Src/init.c +++ b/Src/init.c @@ -248,7 +248,8 @@ static int restricted; /**/ static void -parseargs(char *zsh_name, char **argv, char **runscript, char **cmdptr) +parseargs(char *zsh_name, char **argv, char **runscript, char **cmdptr, + int *needkeymap) { char **x; LinkList paramlist; @@ -265,7 +266,7 @@ parseargs(char *zsh_name, char **argv, char **runscript, char **cmdptr) * matched by code at the end of the present function. */ - if (parseopts(zsh_name, &argv, opts, cmdptr, NULL, flags)) + if (parseopts(zsh_name, &argv, opts, cmdptr, NULL, flags, needkeymap)) exit(1); /* @@ -376,7 +377,7 @@ static void parseopts_setemulate(char *nam, int flags) /**/ mod_export int parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp, - LinkList optlist, int flags) + LinkList optlist, int flags, int *needkeymap) { int optionbreak = 0; int action, optno; @@ -482,8 +483,14 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp, return 1; } else if (optno == RESTRICTED && toplevel) { restricted = action; - } else if ((optno == EMACSMODE || optno == VIMODE) && !toplevel) { - WARN_OPTION("can't change option: %s", *argv); + } else if ((optno == EMACSMODE || optno == VIMODE) + && (!toplevel || needkeymap)){ + if (!toplevel) { + WARN_OPTION("can't change option: %s", *argv); + } else { + /* Need to wait for modules to be loadable */ + *needkeymap = optno; + } } else { if (dosetopt(optno, action, toplevel, new_opts) && !toplevel) { @@ -1035,7 +1042,6 @@ setupvals(char *cmd, char *runscript, char *zsh_name) #endif /* FPATH_NEEDS_INIT */ mailpath = mkarray(NULL); - watch = mkarray(NULL); psvar = mkarray(NULL); module_path = mkarray(ztrdup(MODULE_DIR)); modulestab = newmoduletable(17, "modules"); @@ -1705,7 +1711,7 @@ zsh_main(UNUSED(int argc), char **argv) { char **t, *runscript = NULL, *zsh_name; char *cmd; /* argument to -c */ - int t0; + int t0, needkeymap = 0; #ifdef USE_LOCALE setlocale(LC_ALL, ""); #endif @@ -1751,7 +1757,7 @@ zsh_main(UNUSED(int argc), char **argv) createoptiontable(); /* sets emulation, LOGINSHELL, PRIVILEGED, ZLE, INTERACTIVE, * SHINSTDIN and SINGLECOMMAND */ - parseargs(zsh_name, argv, &runscript, &cmd); + parseargs(zsh_name, argv, &runscript, &cmd, &needkeymap); SHTTY = -1; init_io(cmd); @@ -1760,6 +1766,15 @@ zsh_main(UNUSED(int argc), char **argv) init_signals(); init_bltinmods(); init_builtins(); + + if (needkeymap) + { + /* Saved for after module system initialisation */ + zleentry(ZLE_CMD_SET_KEYMAP, needkeymap); + opts[needkeymap] = 1; + opts[needkeymap == EMACSMODE ? VIMODE : EMACSMODE] = 0; + } + run_init_scripts(); setupshin(runscript); init_misc(cmd, zsh_name); |