Subject: bin/4465: vi reports funny error message when TERM not set
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon Burge <simonb@telstra.com.au>
List: netbsd-bugs
Date: 11/11/1997 16:00:00
>Number:         4465
>Category:       bin
>Synopsis:       vi reports funny error message when TERM not set
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 10 21:05:02 1997
>Last-Modified:
>Originator:     Simon Burge
>Organization:
	IBM Global Services Australia
>Release:        NetBSD-1.3_ALPHA (early November 1997)
>Environment:
System: NetBSD vlad 1.3_ALPHA NetBSD 1.3_ALPHA (MONA) #1: Tue Nov 11 09:56:22 EST 1997 simonb@vlad:/usr/src/sys/arch/pmax/compile/MONA pmax


>Description:
        If the TERM variable is not set, vi reports the following error
        message:
		
		ex/vi: Error: unknown: No such file or directory

>How-To-Repeat:
        Make sure the TERM variable isn't set, then:

		% vi

        and watch the non-descriptive sparks.

>Fix:
        Not sure...

        In the cl_vi_init() function in vi/cl/cl_screen.c, there's a
        call to newterm(), which simply calls curses' initscr().  If
        errno is set after this, it prints the error associated with
        that value.  If errno is not set, then it prints the message
        about "unknown terminal type".

        It looks initscr() (or something it calls) is setting errno to
        ENOENT if $TERM isn't set, but I can't find a reference to this
        anywhere obvious.

        The following does the trick though:

*** vi/cl/cl_screen.c.ORIG	Mon May 20 22:17:00 1996
--- vi/cl/cl_screen.c	Tue Nov 11 15:49:35 1997
***************
*** 244,250 ****
  	 */
  	errno = 0;
  	if (newterm(ttype, stdout, stdin) == NULL) {
! 		if (errno)
  			msgq(sp, M_SYSERR, "%s", ttype);
  		else
  			msgq(sp, M_ERR, "%s: unknown terminal type", ttype);
--- 244,250 ----
  	 */
  	errno = 0;
  	if (newterm(ttype, stdout, stdin) == NULL) {
! 		if (errno && errno != ENOENT)
  			msgq(sp, M_SYSERR, "%s", ttype);
  		else
  			msgq(sp, M_ERR, "%s: unknown terminal type", ttype);
>Audit-Trail:
>Unformatted: