From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: [Fwd: Re: -o nobanghist -o emacs segfaults]
Date: Sun, 05 Apr 2020 21:11:23 +0100 [thread overview]
Message-ID: <76ea2f7e3a38e4a9cecfbdddaa2e0c82b0e6c22b.camel@ntlworld.com> (raw)
In-Reply-To: <2d822470aac6bdf9927d1675326de0b60f03eea7.camel@ntlworld.com>
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
Sorry, was supposed to go to the list...
-------- Forwarded Message --------
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Subject: Re: -o nobanghist -o emacs segfaults
Date: Sun, 05 Apr 2020 20:41:11 +0100
On Sun, 2020-04-05 at 05:46 +0000, Daniel Shahaf wrote:
> Peter Stephenson wrote on Fri, 03 Apr 2020 11:15 +0100:
> > > On 03 April 2020 at 09:11 Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > > % b/Src/zsh -f -o nobanghist -o emacs
> > > zsh: segmentation fault b/Src/zsh -f -o nobanghist -o emacs
The attached isn't particularly glorious, but I think it fixes the
problem (tried with both emacs and vi to make sure).
pws
[-- Attachment #2: init_keymap.dif --]
[-- Type: text/x-patch, Size: 3174 bytes --]
diff --git a/Src/builtin.c b/Src/builtin.c
index 407cad159..3dab3f9b4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -6119,7 +6119,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)) {
+ if (parseopts(nam, &argv, new_opts, &cmd, optlist, 0, NULL)) {
ret = 1;
goto restore;
}
diff --git a/Src/init.c b/Src/init.c
index 04a5856ff..3d6c94d04 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) {
@@ -1707,7 +1714,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
@@ -1753,7 +1760,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);
@@ -1762,6 +1769,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);
parent reply other threads:[~2020-04-05 20:12 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <2d822470aac6bdf9927d1675326de0b60f03eea7.camel@ntlworld.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76ea2f7e3a38e4a9cecfbdddaa2e0c82b0e6c22b.camel@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).