From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29308 invoked from network); 24 Aug 2001 23:06:55 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 24 Aug 2001 23:06:55 -0000 Received: (qmail 16287 invoked by alias); 24 Aug 2001 23:06:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15707 Received: (qmail 16276 invoked from network); 24 Aug 2001 23:06:43 -0000 From: Bart Schaefer Message-Id: <010824160035.ZM28716@candle.brasslantern.com> Date: Fri, 24 Aug 2001 16:00:35 -0700 In-Reply-To: <2796937.998645002276.JavaMail.root@suntea.algonet.se> Comments: In reply to Thomas Eriksson "Re: zsh segfault" (Aug 24, 11:23am) References: <2796937.998645002276.JavaMail.root@suntea.algonet.se> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Thomas Eriksson , zsh-workers@sunsite.dk Subject: Re: zsh segfault MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 24, 11:23am, Thomas Eriksson wrote: > > printf "unset -f precmd \n" 1>/home/arne/wuf > alias wuf="echo wuf wuf;precmd () { . /home/arne/wuf ; }" > wuf The alias isn't necessary; so is the unset -f. Any "." or "source" command from within precmd() gives: BUG: chline is NULL in hend() (which is only visible with configure --enable-zsh-debug). This is happening because source() re-enters loop(), which clobbers the hbegin(1) at the top of the function. The following fixes it, but I'm wondering if there's a better way. (The reason this doesn't happen in 3.0.x is that the hbegin() in loop() happens later, after preprompt() -- but 4.0.x has a bunch of special variables that might be used in `precmd' and that refer to the history, so the initialization has to happen sooner.) Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.18.4.1 diff -c -r1.18.4.1 init.c --- Src/init.c 2001/06/30 18:30:07 1.18.4.1 +++ Src/init.c 2001/08/24 22:53:36 @@ -107,6 +107,8 @@ pushheap(); for (;;) { freeheap(); + if (stophist == 3) /* re-entry via preprompt() */ + hend(NULL); hbegin(1); /* init history mech */ if (isset(SHINSTDIN)) { setblock_stdin(); @@ -114,7 +116,10 @@ int hstop = stophist; stophist = 3; preprompt(); - stophist = hstop; + if (stophist != 3) + hbegin(1); + else + stophist = hstop; errflag = 0; } }