Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bang completion kills zsh in emacs process buffer



"Dwight Shih" wrote:
> Peter,
> 
> zsh thinks that it's an interactive shell because emacs invokes it with
> the -i option.

OK, I think I see what's going on now.

!-history is in use because:
 - the shell is interactive, and
 - shell input is standard input

shout gets set if:
  - the shell is interactive, and
  - SHTTY is set

SHTTY is set if and only we are talking to a tty on fd 0, and we aren't.
We can't very well set it or shout in that case.  (We could in principle
look harder for a tty, but that's not the issue here --- there just
isn't one.)

In that case, I think the right thing to do might be the following.
Presumably this bug has been there forever.

Comments?

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.46
diff -u -r1.46 hist.c
--- Src/hist.c	11 Aug 2003 13:19:55 -0000	1.46
+++ Src/hist.c	19 Sep 2003 17:17:09 -0000
@@ -1091,9 +1091,16 @@
 
 	ptr = ztrdup(chline);
 	if ((flag & (HISTFLAG_DONE | HISTFLAG_RECALL)) == HISTFLAG_DONE) {
-	    zputs(ptr, shout);
-	    fputc('\n', shout);
-	    fflush(shout);
+	    /*
+	     * If fd 0 isn't a tty, we may not have a shout, even
+	     * though the shell is interactive.  Observed with
+	     * Emacs shell mode, which makes the shell interactive
+	     * explicitly.
+	     */
+	    FILE *fout = shout ? shout : stdout;
+	    zputs(ptr, fout);
+	    fputc('\n', fout);
+	    fflush(fout);
 	}
 	if (flag & HISTFLAG_RECALL) {
 	    zpushnode(bufstack, ptr);

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author