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

PATCH: 3.1.5* & 3.0.5: Re: strange xterm & zsh behaviour



Drazen Kacar wrote:
> Drazen Kacar wrote:
> 
> > > } Control keys and arrow keys don't work any
> > > } more. The shell just echos ^[[A (for example) instead of scrolling
> > > } through the history list. Ctrl-C is being echoed as ^C and the shell
> > > } doesn't prompt in a new line.
> 
> Here's the patch for zsh 3.0.5 which fixes that:

The code for 3.1.5 is similar, so the same ought to work.  It's pretty
much impossible to test in configure, and it'll only try it if it
really needs it, so probably it's OK to have the code run for all
OSes.  The worst that can happen is that you get a read-only terminal,
but the alternative is no terminal at all.

I added a free for ttystrname to match the other bits.  Any more
comments?

*** Src/init.c.tty	Thu Dec 17 12:17:04 1998
--- Src/init.c	Fri Jan 29 10:13:19 1999
***************
*** 309,314 ****
--- 309,330 ----
  	zsfree(ttystrname);
  	ttystrname = ztrdup("/dev/tty");
      }
+     /*
+      * xterm, rxvt and probably all terminal emulators except dtterm on
+      * Solaris 2.6 & 7 have a bug. Applications are unable to open /dev/tty
+      * or /dev/pts/<terminal number here> because something in Sun's STREAMS
+      * modules doesn't like it. The open() call fails with EBUSY which
+      * is not even listed as a possibility in the open(2) man page.
+      * So we'll try to outsmart The Company.  -- <dave@xxxxxxx>
+      *
+      * Presumably there's no harm trying this on any OS, given that
+      * isatty(0) worked but opening the tty didn't.  Possibly we won't
+      * get the tty read/write, but it's the best we can do -- pws
+      */
+     if (SHTTY == -1 && isatty(0) && (SHTTY = movefd(dup(0))) != -1) {
+ 	zsfree(ttystrname);
+ 	ttystrname = ztrdup(ttyname(0));
+     }
      if (SHTTY == -1) {
  	zsfree(ttystrname);
  	ttystrname = ztrdup("");

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy




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