🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #309

key binding/stty character conflict

#309
From: Ray Nickson
Date: Wed, 12 Jul 1989 22:36
84 lines
3230 bytes
ENVIRONMENT: bash 1.01 or 1.02 on an HP300 running MORE/BSD4.3
(although I believe it applies to any BSD system).

SYMPTOM: in the command-line editor, some commands don't work.

BUG: there is a conflict between the shell's interpretation of certain
keystrokes and the terminal driver's.  In my case, ^C, ^\, ^Z and ^Y are
bound (by stty) to INTR, QUIT, SUSP and DSUSP, so these keys (^Y in
particular) are not available for the shell.

FIX: we should save and zero the special characters before preparing
the terminal for command-line editing, and restore them when running
subprograms or editing.  The following cdiff for version 1.02 has been
tested in the above environment and appears to work; a similar patch
to readline.c in 1.01 should also work.

BTW: perhaps we should think about doing a full `tty sanity check and
restore' like tcsh does???

-rgn
--
nickson@comp.vuw.ac.nz       ...!uunet!vuwcomp!nickson      + 64 4 721000x8142


--------------------cut here--------------------
*** lib/readline.c.orig	Wed Jul 12 15:17:01 1989
--- lib/readline.c	Thu Jul 13 10:22:14 1989
***************
*** 1483,1494 ****
  
  int original_tty_flags = 0;
  struct sgttyb the_ttybuff;
  
  /* Put the terminal in CBREAK mode so that we can detect key presses. */
  rl_prep_terminal ()
  {
    int tty = fileno (rl_instream);
! 
    /* We always get the latest tty values.  Maybe stty changed them. */
  
    ioctl (tty, TIOCGETP, &the_ttybuff);
--- 1483,1498 ----
  
  int original_tty_flags = 0;
  struct sgttyb the_ttybuff;
+ struct tchars the_tchars;
+ struct ltchars the_ltchars;
  
  /* Put the terminal in CBREAK mode so that we can detect key presses. */
  rl_prep_terminal ()
  {
    int tty = fileno (rl_instream);
!   static struct tchars new_tchars = { -1, -1, -1, -1, -1, -1};
!   static struct ltchars new_ltchars = { -1, -1, -1, -1, -1, -1 };
!   
    /* We always get the latest tty values.  Maybe stty changed them. */
  
    ioctl (tty, TIOCGETP, &the_ttybuff);
***************
*** 1503,1508 ****
--- 1507,1517 ----
      }
    the_ttybuff.sg_flags |= CBREAK;
    ioctl (tty, TIOCSETN, &the_ttybuff);
+   /* save the special characters so we can use them for shell bindings */
+   ioctl (tty, TIOCGETC, &the_tchars);
+   ioctl (tty, TIOCGLTC, &the_ltchars);
+   ioctl (tty, TIOCSETC, &new_tchars);
+   ioctl (tty, TIOCSLTC, &new_ltchars);
  }
  
  /* Restore the terminal to its original state. */
***************
*** 1513,1518 ****
--- 1522,1530 ----
    the_ttybuff.sg_flags = original_tty_flags;
    ioctl (tty, TIOCSETN, &the_ttybuff);
    readline_echoing_p = 1;
+   /* restore special characters to saved values */
+   ioctl (tty, TIOCSETC, &the_tchars);
+   ioctl (tty, TIOCSLTC, &the_ltchars);
  }
  #endif  /* SYSV || HPUX */
  
Technical Details
Message-ID: <8907122237.AA10749@comp.vuw.ac.nz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!comp.vuw.ac.nz!nickson

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!comp.vuw.ac.nz!nickson
From: nickson@comp.vuw.ac.nz (Ray Nickson)
Newsgroups: gnu.bash.bug
Subject: key binding/stty character conflict
Message-ID: <8907122237.AA10749@comp.vuw.ac.nz>
Date: 12 Jul 89 22:36:45 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 84