Subject: Re: bash terminal weirdness
To: None <netbsd-help@NetBSD.ORG>
From: Jim Wight <J.K.Wight@newcastle.ac.uk>
List: netbsd-help
Date: 03/23/1995 10:00:47
"Neil J. McRae" writes:
> Does anyone know why bash gives the staircase effect when executing normal
> commands, I've tried the stty settings to no avail.

I found a similar thing under i386 NetBSD with the rc shell after
incorporating the GNU readline library, which I imagine bash also
uses. rc was OK without the library so I started looking at the
readline source (version 2.0) for a possible explanation - I too tried
all sorts of stty settings without success.

As far as I can see it all hinges on this function in readline.c

/* Move to the start of the next line. */
crlf ()
{
#if defined (NEW_TTY_DRIVER)
  tputs (term_cr, 1, _rl_output_character_function);
#endif /* NEW_TTY_DRIVER */
  putc ('\n', out_stream);
  return 0;
}

As a temporary fix I have unilaterally made the tputs call, and that
appears to have cured my problem, so the question boils down to why
NEW_TTY_DRIVER is not being defined in NetBSD's case. Maybe someone
can figure it out from the following mess in rldefs.h.

#define NEW_TTY_DRIVER
#define HAVE_BSD_SIGNALS
/* #define USE_XON_XOFF */

#if defined (__linux__) || defined (HAVE_TERMCAP_H)
#  include <termcap.h>
#endif /* __linux__ || HAVE_TERMCAP_H */

/* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
#if defined (USG) && !defined (hpux)
#  undef HAVE_BSD_SIGNALS
#endif

/* System V machines use termio. */
#if !defined (_POSIX_VERSION)
#  if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || \
      defined (DGUX) || defined (HAVE_TERMIO_H)
#    undef NEW_TTY_DRIVER
#    define TERMIO_TTY_DRIVER
#    include <termio.h>
#    if !defined (TCOON)
#      define TCOON 1
#    endif
#  endif /* USG || hpux || Xenix || sgi || DUGX || HAVE_TERMIO_H */
#endif /* !_POSIX_VERSION */

/* Posix systems use termios and the Posix signal functions. */
#if defined (_POSIX_VERSION)
#  if !defined (TERMIOS_MISSING)
#    undef NEW_TTY_DRIVER
#    define TERMIOS_TTY_DRIVER
#    include <termios.h>
#  endif /* !TERMIOS_MISSING */
#  define HAVE_POSIX_SIGNALS
#  if !defined (O_NDELAY)
#    define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */
#  endif /* O_NDELAY */
#endif /* _POSIX_VERSION */

/* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
#  if defined (USGr3) && !defined (XENIX_22)
#    if !defined (HAVE_USG_SIGHOLD)
#      define HAVE_USG_SIGHOLD
#    endif /* !HAVE_USG_SIGHOLD */
#  endif /* USGr3 && !XENIX_22 */
#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */

/* Other (BSD) machines use sgtty. */
#if defined (NEW_TTY_DRIVER)
#  include <sgtty.h>
#endif

/* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
   it is not already defined.  It is used both to determine if a
   special character is disabled and to disable certain special
   characters.  Posix systems should set to 0, USG systems to -1. */
#if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
#  if defined (_POSIX_VERSION)
#    define _POSIX_VDISABLE 0
#  else /* !_POSIX_VERSION */
#    define _POSIX_VDISABLE -1
#  endif /* !_POSIX_VERSION */
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */


Of course there's always the possibility that ensuring NEW_TTY_DRIVER
is defined for the crlf case will break something else elsewhere in
the code, so a deeper investigation of the implications, which I'm not
prepared to do at the moment, is almost certainly required.

Jim
---
J.K.Wight@newcastle.ac.uk
Department of Computing Science, University of Newcastle, Tel: +44 191 222 8238
Newcastle upon Tyne, NE1 7RU, United Kingdom.             Fax: +44 191 222 8232