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

Re: Bang completion kills zsh in emacs process buffer



"Dwight Shih" wrote:
> But grepping about the
> source shows that shout is often treated as synonymous with interactive.
> For example, checkrmall will silently succeed if shout is null. Command
> correction (setopt correct) also just writes to shout. I think that we'd
> be better off setting shout whenever we have an interactive shell.

As long as we can rely on things not testing shout to see if there
terminal is set up... usually SHTTY is used for that purpose, so maybe
this is OK, but possibly we are increasing the danger from the existing
conflict of purposes between the various options, SHTTY and shout.

Other bits of the code seemd to think stderr rather than stdout was a
better substitute for shout, which is probably true.

It looks like the only place we need to be careful when closing shout is
the one in init, below.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.35
diff -u -r1.35 init.c
--- Src/init.c	3 Sep 2003 10:15:36 -0000	1.35
+++ Src/init.c	19 Sep 2003 18:13:57 -0000
@@ -379,7 +379,13 @@
 #endif
 
     if (shout) {
-	fclose(shout);
+	/*
+	 * Check if shout was set to stderr, if so don't close it.
+	 * We do this if we are interactive but don't have a
+	 * terminal.
+	 */
+	if (shout != stderr)
+	    fclose(shout);
 	shout = 0;
     }
     if (SHTTY != -1) {
@@ -448,9 +454,9 @@
 
     /* We will only use zle if shell is interactive, *
      * SHTTY != -1, and shout != 0                   */
-    if (interact && SHTTY != -1) {
+    if (interact) {
 	init_shout();
-	if(!shout)
+	if(!SHTTY || !shout)
 	    opts[USEZLE] = 0;
     } else
 	opts[USEZLE] = 0;
@@ -475,6 +481,14 @@
 init_shout(void)
 {
     static char shoutbuf[BUFSIZ];
+
+    if (SHTTY == -1)
+    {
+	/* Since we're interative, it's nice to have somewhere to write. */
+	shout = stderr;
+	return;
+    }
+
 #if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC)
     int ldisc = NTTYDISC;
 
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.21
diff -u -r1.21 jobs.c
--- Src/jobs.c	2 May 2003 10:25:33 -0000	1.21
+++ Src/jobs.c	19 Sep 2003 18:13:57 -0000
@@ -322,8 +322,9 @@
 	}
     }
 
-    if (shout && !ttyfrozen && !jn->stty_in_env && !zleactive &&
-	job == thisjob && !somestopped && !(jn->stat & STAT_NOSTTY))
+    if (shout && shout != stderr && !ttyfrozen && !jn->stty_in_env &&
+	!zleactive && job == thisjob && !somestopped &&
+	!(jn->stat & STAT_NOSTTY)) 
 	gettyinfo(&shttyinfo);
 
     if (isset(MONITOR)) {

-- 
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