From f8d93888a8efd6c8142e74ece83b38632661de47 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Wed, 2 Nov 2022 16:27:27 +0900 Subject: 50851: restore typtab when necessary inittyptab() must be called when returning from a function with "setopt localoptions MULTIBYTE|BANGHIST|SHSTDIN", and also in function dosetopt() when setting these options (via $options, for example). We intentionally did not take account of the options EMACS/VI because these options are obsolete and their use is not recommended. --- Src/options.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Src/options.c') diff --git a/Src/options.c b/Src/options.c index a1fe918fc..a994b563e 100644 --- a/Src/options.c +++ b/Src/options.c @@ -904,7 +904,11 @@ dosetopt(int optno, int value, int force, char *new_opts) keyboardhackchar = (value ? '`' : '\0'); } new_opts[optno] = value; - if (optno == BANGHIST || optno == SHINSTDIN) + if ( +#ifdef MULTIBYTE_SUPPORT + optno == MULTIBYTE || +#endif + optno == BANGHIST || optno == SHINSTDIN) inittyptab(); return 0; } -- cgit v1.2.3 From f1e7481b8690a6ef71a83853f05645cb774778ab Mon Sep 17 00:00:00 2001 From: Stephane Chazelas Date: Sun, 18 Feb 2024 18:52:50 +0000 Subject: 45837: fix process group restoration upon exit --- ChangeLog | 6 ++++++ Src/exec.c | 2 +- Src/init.c | 13 ++++++++----- Src/options.c | 7 ++++--- 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'Src/options.c') diff --git a/ChangeLog b/ChangeLog index 9afb3e41c..cebc7c6ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-02-18 Stephane Chazelas + + * 45837: Src/exec.c, Src/init.c, Src/options.c: fix issue whereby + original process group is not restored properly upon exit when + exec {var} redirs are used or MONITOR is temporarily disabled. + 2024-02-18 Stephane Chazelas * 52515: Src/exec.c (+ tests in 52527) avoid sh errors when diff --git a/Src/exec.c b/Src/exec.c index 9c8bbb458..1565cb13e 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3768,7 +3768,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, addfd(forked, save, mfds, fn->fd1, fil, 0, fn->varid); /* If this is 'exec < file', read from stdin, * * not terminal, unless `file' is a terminal. */ - if (nullexec == 1 && fn->fd1 == 0 && + if (nullexec == 1 && fn->fd1 == 0 && !fn->varid && isset(SHINSTDIN) && interact && !zleactive) init_io(NULL); break; diff --git a/Src/init.c b/Src/init.c index 799ad19f6..83b79d3d4 100644 --- a/Src/init.c +++ b/Src/init.c @@ -700,11 +700,14 @@ init_io(char *cmd) * process group leader. */ mypid = (zlong)getpid(); - if (opts[MONITOR] && (SHTTY != -1)) { - origpgrp = GETPGRP(); - acquire_pgrp(); /* might also clear opts[MONITOR] */ - } else - opts[MONITOR] = 0; + if (opts[MONITOR]) { + if (SHTTY == -1) + opts[MONITOR] = 0; + else if (!origpgrp) { + origpgrp = GETPGRP(); + acquire_pgrp(); /* might also clear opts[MONITOR] */ + } + } #else opts[MONITOR] = 0; #endif diff --git a/Src/options.c b/Src/options.c index a994b563e..a0e1aa024 100644 --- a/Src/options.c +++ b/Src/options.c @@ -881,11 +881,12 @@ dosetopt(int optno, int value, int force, char *new_opts) } else if (!force && optno == MONITOR && value) { if (new_opts[optno] == value) return 0; - if (SHTTY != -1) { + if (SHTTY == -1) + return -1; + if (!origpgrp) { origpgrp = GETPGRP(); acquire_pgrp(); - } else - return -1; + } #else } else if(optno == MONITOR && value) { return -1; -- cgit v1.2.3 From 8dd271fdec526241ad3ed9c7f2641127a939893c Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sat, 14 Sep 2024 19:21:58 +0200 Subject: 53081: remove old BeOS support code --- ChangeLog | 3 + INSTALL | 7 --- Src/init.c | 8 +-- Src/options.c | 9 --- Src/signals.c | 7 --- Src/zsh_system.h | 12 ---- configure.ac | 165 ------------------------------------------------------- 7 files changed, 5 insertions(+), 206 deletions(-) (limited to 'Src/options.c') diff --git a/ChangeLog b/ChangeLog index 3301c5287..335ae40d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2024-09-14 Oliver Kiddle + * 53081: INSTALL, configure.ac, Src/init.c, Src/options.c, + Src/signals.c, Src/zsh_system.h: remove old BeOS support code + * 53080: configure.ac, Src/init.c, Src/signals.c, Src/signals.h: remove code for systems that only have the old pre-POSIX signal() diff --git a/INSTALL b/INSTALL index f347a4480..8b139fa9b 100644 --- a/INSTALL +++ b/INSTALL @@ -576,13 +576,6 @@ shell is running in some privileged mode. This is turned off by default as on some systems non-standard headers (in particular AIX) are required. A direct fix for that problem would be appreciated. -A test for the function tcsetpgrp is turned on by default. The test -needs to run the function to determine if the implementation is -usable. However, this can cause problems when configure is run without -a controlling terminal (eg. from cron). To avoid this, use ---with-tcsetpgrp or --without-tcsetpgrp to tell configure whether the -function should be used. - Options For Configure --------------------- diff --git a/Src/init.c b/Src/init.c index 8c7776c7a..70e878e20 100644 --- a/Src/init.c +++ b/Src/init.c @@ -695,7 +695,6 @@ init_io(char *cmd) } else opts[USEZLE] = 0; -#ifdef JOB_CONTROL /* If interactive, make sure the shell is in the foreground and is the * process group leader. */ @@ -708,9 +707,6 @@ init_io(char *cmd) acquire_pgrp(); /* might also clear opts[MONITOR] */ } } -#else - opts[MONITOR] = 0; -#endif } /**/ @@ -718,7 +714,7 @@ mod_export void init_shout(void) { static char shoutbuf[BUFSIZ]; -#if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC) +#if defined(TIOCSETD) && defined(NTTYDISC) int ldisc; #endif @@ -729,7 +725,7 @@ init_shout(void) return; } -#if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC) +#if defined(TIOCSETD) && defined(NTTYDISC) ldisc = NTTYDISC; ioctl(SHTTY, TIOCSETD, (char *)&ldisc); #endif diff --git a/Src/options.c b/Src/options.c index a0e1aa024..8b37ab5e8 100644 --- a/Src/options.c +++ b/Src/options.c @@ -877,7 +877,6 @@ dosetopt(int optno, int value, int force, char *new_opts) } #endif /* HAVE_SETRESGID && HAVE_SETRESUID */ -#ifdef JOB_CONTROL } else if (!force && optno == MONITOR && value) { if (new_opts[optno] == value) return 0; @@ -887,14 +886,6 @@ dosetopt(int optno, int value, int force, char *new_opts) origpgrp = GETPGRP(); acquire_pgrp(); } -#else - } else if(optno == MONITOR && value) { - return -1; -#endif /* not JOB_CONTROL */ -#ifdef GETPWNAM_FAKED - } else if(optno == CDABLEVARS && value) { - return -1; -#endif /* GETPWNAM_FAKED */ } else if ((optno == EMACSMODE || optno == VIMODE) && value) { if (sticky && sticky->emulation) return -1; diff --git a/Src/signals.c b/Src/signals.c index 6eecbf7d5..86f1a49f6 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -216,7 +216,6 @@ signal_suspend(UNUSED(int sig), int wait_cmd) int ret; sigset_t set; - sigset_t oset; sigemptyset(&set); @@ -229,13 +228,7 @@ signal_suspend(UNUSED(int sig), int wait_cmd) (sigtrapped[SIGINT] & ~ZSIG_IGNORED))) sigaddset(&set, SIGINT); -# ifdef BROKEN_POSIX_SIGSUSPEND - sigprocmask(SIG_SETMASK, &set, &oset); - ret = pause(); - sigprocmask(SIG_SETMASK, &oset, NULL); -# else /* not BROKEN_POSIX_SIGSUSPEND */ ret = sigsuspend(&set); -# endif /* BROKEN_POSIX_SIGSUSPEND */ return ret; } diff --git a/Src/zsh_system.h b/Src/zsh_system.h index 5c004d53e..21446a9b1 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -369,8 +369,6 @@ struct timespec { # ifndef TIME_H_SELECT_H_CONFLICTS # include # endif -#elif defined(SELECT_IN_SYS_SOCKET_H) -# include #endif #if defined(__APPLE__) && defined(HAVE_SELECT) @@ -803,16 +801,6 @@ extern short ospeed; #endif #endif -/* Can't support job control without working tcsetgrp() */ -#ifdef BROKEN_TCSETPGRP -#undef JOB_CONTROL -#endif /* BROKEN_TCSETPGRP */ - -#ifdef BROKEN_KILL_ESRCH -#undef ESRCH -#define ESRCH EINVAL -#endif /* BROKEN_KILL_ESRCH */ - /* Can we do locale stuff? */ #undef USE_LOCALE #if defined(CONFIG_LOCALE) && defined(HAVE_SETLOCALE) && defined(LC_ALL) diff --git a/configure.ac b/configure.ac index eab95105c..b2721fa77 100644 --- a/configure.ac +++ b/configure.ac @@ -2119,20 +2119,6 @@ if test x$zsh_cv_header_sys_ioctl_h_ioctl_proto = xyes; then AC_DEFINE(IOCTL_IN_SYS_IOCTL) fi -dnl ------------------- -dnl select() defined in , ie BeOS R4.51 -dnl ------------------- -AH_TEMPLATE([SELECT_IN_SYS_SOCKET_H], -[Define to 1 if select() is defined in , ie BeOS R4.51]) -if test x$ac_cv_header_sys_select_h != xyes; then - AC_CACHE_CHECK(for select() in , - zsh_cv_header_socket_h_select_proto, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[fd_set fd;]])],[zsh_cv_header_socket_h_select_proto=yes],[zsh_cv_header_socket_h_select_proto=no])]) - if test x$zsh_cv_header_socket_h_select_proto = xyes; then - AC_DEFINE(SELECT_IN_SYS_SOCKET_H) - fi -fi - dnl ----------- dnl named FIFOs dnl ----------- @@ -2266,154 +2252,6 @@ if test x$zsh_cv_sys_link = xyes; then AC_DEFINE(HAVE_LINK) fi -dnl ----------- -dnl test for whether kill(pid, 0) where pid doesn't exit -dnl should set errno to ESRCH, but some like BeOS R4.51 set to EINVAL -dnl ----------- -AC_CACHE_CHECK(if kill(pid, 0) returns ESRCH correctly, -zsh_cv_sys_killesrch, -[AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -int main() -{ - int pid = (getpid() + 10000) & 0xffffff; - while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1; - return(errno!=ESRCH); -} -]])],[zsh_cv_sys_killesrch=yes],[zsh_cv_sys_killesrch=no],[zsh_cv_sys_killesrch=yes])]) -AH_TEMPLATE([BROKEN_KILL_ESRCH], -[Define to 1 if kill(pid, 0) doesn't return ESRCH, ie BeOS R4.51.]) -if test x$zsh_cv_sys_killesrch = xno; then - AC_DEFINE(BROKEN_KILL_ESRCH) -fi - -dnl ----------- -dnl if POSIX, test for working sigsuspend(). -dnl for instance, BeOS R4.51 is broken. -dnl ----------- -AH_TEMPLATE([BROKEN_POSIX_SIGSUSPEND], -Define to 1 if sigsuspend() is broken, ie BeOS R4.51.]) - AC_CACHE_CHECK(if POSIX sigsuspend() works, - zsh_cv_sys_sigsuspend, - [AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -int child=0; -void handler(sig) - int sig; -{if(sig==SIGCHLD) child=1;} -int main() { - struct sigaction act; - sigset_t set; - int pid, ret; - act.sa_handler = &handler; - sigfillset(&act.sa_mask); - act.sa_flags = 0; - sigaction(SIGCHLD, &act, 0); - sigfillset(&set); - sigprocmask(SIG_SETMASK, &set, 0); - pid=fork(); - if(pid==0) return 0; - if(pid>0) { - sigemptyset(&set); - ret=sigsuspend(&set); - return(child==0); - } -} -]])],[zsh_cv_sys_sigsuspend=yes],[zsh_cv_sys_sigsuspend=no],[zsh_cv_sys_sigsuspend=yes])]) - if test x$zsh_cv_sys_sigsuspend = xno; then - AC_DEFINE(BROKEN_POSIX_SIGSUSPEND) - fi - -dnl ----------- -dnl if found tcsetpgrp, test to see if it actually works -dnl for instance, BeOS R4.51 does not support it yet -dnl ----------- -AH_TEMPLATE([BROKEN_TCSETPGRP], -[Define to 1 if tcsetpgrp() doesn't work, ie BeOS R4.51.]) -AC_ARG_WITH(tcsetpgrp, -AS_HELP_STRING([--with-tcsetpgrp],[assumes that tcsetpgrp() exists and works correctly]),[ -case "x$withval" in - xyes) zsh_working_tcsetpgrp=yes;; - xno) zsh_working_tcsetpgrp=no;; - *) AC_MSG_ERROR(please use --with-tcsetpgrp=yes or --with-tcsetpgrp=no);; -esac],[zsh_working_tcsetpgrp=check]) -if test "x$ac_cv_func_tcsetpgrp" = xyes; then -case "x$zsh_working_tcsetpgrp" in - xcheck) - trap "" TTOU > /dev/null 2>&1 || : - AC_CACHE_CHECK(if tcsetpgrp() actually works, - zsh_cv_sys_tcsetpgrp, - [AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -int main() { - int fd; - int ret; - fd=open("/dev/tty", O_RDWR); - if (fd < 0) return(2); - ret=tcsetpgrp(fd, tcgetpgrp(fd)); - if (ret < 0) return(1); - return(0); -} -]])],[zsh_cv_sys_tcsetpgrp=yes],[ -case $? in - 1) zsh_cv_sys_tcsetpgrp=no;; - 2) zsh_cv_sys_tcsetpgrp=notty;; - *) zsh_cv_sys_tcsetpgrp=error;; -esac - ],[zsh_cv_sys_tcsetpgrp=yes])]) - case "x$zsh_cv_sys_tcsetpgrp" in - xno) AC_DEFINE(BROKEN_TCSETPGRP);; - xyes) :;; - xnotty) AC_MSG_ERROR([no controlling tty -Try running configure with --with-tcsetpgrp or --without-tcsetpgrp]);; - *) AC_MSG_ERROR([unexpected return status]);; - esac - trap - TTOU > /dev/null 2>&1 || : - ;; - xyes) :;; - xno) AC_DEFINE(BROKEN_TCSETPGRP);; - *) AC_MSG_ERROR([unexpected value zsh_working_tcsetpgrp=$zsh_working_tcsetpgrp]);; -esac -fi - -dnl ----------- -dnl test for faked getpwnam() entry, ie a single entry returned for any username -dnl for instance, BeOS R4.51 is not multiuser yet, and fakes getpwnam() -dnl test by looking up two usernames that shouldn't succeed, and compare entry -dnl ----------- -AH_TEMPLATE([GETPWNAM_FAKED], -[Define to 1 if getpwnam() is faked, ie BeOS R4.51.]) -if test x$ac_cv_func_getpwnam = xyes; then - AC_CACHE_CHECK(if getpwnam() is faked, - zsh_cv_sys_getpwnam_faked, - [AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -#include -#include -int main() { - struct passwd *pw1, *pw2; - char buf[1024], name[1024]; - sprintf(buf, "%d:%d", getpid(), rand()); - pw1=getpwnam(buf); - if (pw1) strcpy(name, pw1->pw_name); - sprintf(buf, "%d:%d", rand(), getpid()); - pw2=getpwnam(buf); - return(pw1!=0 && pw2!=0 && !strcmp(name, pw2->pw_name)); -} -]])],[zsh_cv_sys_getpwnam_faked=no],[zsh_cv_sys_getpwnam_faked=yes],[zsh_cv_sys_getpwnam_faked=no])]) - if test x$zsh_cv_sys_getpwnam_faked = xyes; then - AC_DEFINE(GETPWNAM_FAKED) - fi -fi - - dnl --------------- dnl check for the type of third argument of accept dnl --------------- @@ -3151,9 +2989,6 @@ AH_TOP([/***** begin user configuration section *****/ /* Define to 1 if you want user names to be cached */ #define CACHE_USERNAMES 1 -/* Define to 1 if system supports job control */ -#define JOB_CONTROL 1 - /* Define this if you use "suspended" instead of "stopped" */ #define USE_SUSPENDED 1 -- cgit v1.2.3 From d315401a032cfada4ff733b20d708a5e76d75e48 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 2 Mar 2025 11:23:22 -0800 Subject: 53368: ignore no-op changes to EMACS/VI options --- ChangeLog | 4 ++++ Src/options.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'Src/options.c') diff --git a/ChangeLog b/ChangeLog index 8cc81f4b4..340a39479 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2025-03-02 Bart Schaefer + + * 53368: Src/options.c: ignore no-op changes to EMACS/VI options + 2025-02-28 Oliver Kiddle * 53395: Completion/Unix/Type/_zfs_dataset, diff --git a/Src/options.c b/Src/options.c index 8b37ab5e8..696ab5c69 100644 --- a/Src/options.c +++ b/Src/options.c @@ -887,8 +887,14 @@ dosetopt(int optno, int value, int force, char *new_opts) acquire_pgrp(); } } else if ((optno == EMACSMODE || optno == VIMODE) && value) { + /* What's going on here: + * 1) unsetopt of either emacs or vi is an effective no-op. + * 2) setopt of either emacs or vi toggles off the other. + * Hence we disallow changing these options in emulation mode, + * but only if the change is setopt rather than unsetopt. + */ if (sticky && sticky->emulation) - return -1; + return opts[optno] ? 0 : -1; zleentry(ZLE_CMD_SET_KEYMAP, optno); new_opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0; } else if (optno == SUNKEYBOARDHACK) { -- cgit v1.2.3 From 435cb1b748ce1f2f5c38edc1d64f4ee2424f9b3a Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 3 Mar 2025 01:24:46 +0100 Subject: 53399: don't load ZLE early to set keymap When zsh is run with -o vi / -o emacs, instead of loading ZLE to force the change, only record the option state. Then when ZLE starts, the vi option determines the default keymap. --- ChangeLog | 3 +++ Src/Zle/zle_keymap.c | 5 ++++- Src/builtin.c | 2 +- Src/init.c | 30 +++++++----------------------- Src/options.c | 5 +++-- 5 files changed, 18 insertions(+), 27 deletions(-) (limited to 'Src/options.c') diff --git a/ChangeLog b/ChangeLog index 926f36d58..a37a0f2ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2025-03-03 Oliver Kiddle + * 53399: Src/Zle/zle_keymap.c, Src/builtin.c, Src/init.c, + Src/options.c: don't load ZLE early to set keymap + * 53394: Src/Zle/zle_keymap.c: drop OSC and DCS sequences in key input as they are likely to be terminal query responses not keys diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index ce52abe66..7f31f837c 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1452,7 +1452,10 @@ default_bindings(void) linkkeymap(oppmap, "viopp", 0); linkkeymap(vismap, "visual", 0); linkkeymap(smap, ".safe", 1); - linkkeymap(emap, "main", 0); + if (isset(VIMODE)) + linkkeymap(vmap, "main", 0); + else + linkkeymap(emap, "main", 0); /* the .safe map cannot be modified or deleted */ smap->flags |= KM_IMMUTABLE; diff --git a/Src/builtin.c b/Src/builtin.c index 6bdaddff0..5563bdba9 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -6333,7 +6333,7 @@ bin_emulate(char *nam, char **argv, Options ops, UNUSED(int func)) savehackchar = keyboardhackchar; emulate(shname, opt_R, &new_emulation, new_opts); optlist = newlinklist(); - if (parseopts(nam, &argv, new_opts, &cmd, optlist, 0, NULL)) { + if (parseopts(nam, &argv, new_opts, &cmd, optlist, 0)) { ret = 1; goto restore; } diff --git a/Src/init.c b/Src/init.c index 75d9dd136..76de0b449 100644 --- a/Src/init.c +++ b/Src/init.c @@ -255,8 +255,7 @@ static char *argv0; /**/ static void -parseargs(char *zsh_name, char **argv, char **runscript, char **cmdptr, - int *needkeymap) +parseargs(char *zsh_name, char **argv, char **runscript, char **cmdptr) { char **x; LinkList paramlist; @@ -273,7 +272,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, needkeymap)) + if (parseopts(zsh_name, &argv, opts, cmdptr, NULL, flags)) exit(1); /* @@ -384,7 +383,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, int *needkeymap) + LinkList optlist, int flags) { int optionbreak = 0; int action, optno; @@ -490,14 +489,8 @@ 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 || needkeymap)){ - if (!toplevel) { - WARN_OPTION("can't change option: %s", *argv); - } else { - /* Need to wait for modules to be loadable */ - *needkeymap = optno; - } + } else if ((optno == EMACSMODE || optno == VIMODE) && !toplevel) { + WARN_OPTION("can't change option: %s", *argv); } else { if (dosetopt(optno, action, toplevel, new_opts) && !toplevel) { @@ -1864,7 +1857,7 @@ zsh_main(UNUSED(int argc), char **argv) { char **t, *runscript = NULL, *zsh_name; char *cmd; /* argument to -c */ - int t0, needkeymap = 0; + int t0; #ifdef USE_LOCALE setlocale(LC_ALL, ""); #endif @@ -1910,7 +1903,7 @@ zsh_main(UNUSED(int argc), char **argv) createoptiontable(); /* sets emulation, LOGINSHELL, PRIVILEGED, ZLE, INTERACTIVE, * SHINSTDIN and SINGLECOMMAND */ - parseargs(zsh_name, argv, &runscript, &cmd, &needkeymap); + parseargs(zsh_name, argv, &runscript, &cmd); SHTTY = -1; init_io(cmd); @@ -1919,15 +1912,6 @@ 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); diff --git a/Src/options.c b/Src/options.c index 696ab5c69..8b13f0c5d 100644 --- a/Src/options.c +++ b/Src/options.c @@ -895,8 +895,9 @@ dosetopt(int optno, int value, int force, char *new_opts) */ if (sticky && sticky->emulation) return opts[optno] ? 0 : -1; - zleentry(ZLE_CMD_SET_KEYMAP, optno); - new_opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0; + if (zle_load_state == 1) + zleentry(ZLE_CMD_SET_KEYMAP, optno); + new_opts[optno ^ EMACSMODE ^ VIMODE] = 0; } else if (optno == SUNKEYBOARDHACK) { /* for backward compatibility */ keyboardhackchar = (value ? '`' : '\0'); -- cgit v1.2.3