NetBSD Problem Report #39883

From www@NetBSD.org  Sat Nov  8 02:26:27 2008
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id CA1BA63BD86
	for <gnats-bugs@gnats.netbsd.org>; Sat,  8 Nov 2008 02:26:27 +0000 (UTC)
Message-Id: <20081108022627.9C9B363BD76@narn.NetBSD.org>
Date: Sat,  8 Nov 2008 02:26:27 +0000 (UTC)
From: mikel@mikelward.com
Reply-To: mikel@mikelward.com
To: gnats-bugs@NetBSD.org
Subject: tput support for setaf terminfo sequence is broken
X-Send-Pr-Version: www-1.0

>Number:         39883
>Category:       bin
>Synopsis:       tput support for setaf terminfo sequence is broken
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jnemeth
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 08 02:30:05 +0000 2008
>Closed-Date:    Thu Nov 29 00:29:10 +0000 2012
>Last-Modified:  Thu Nov 29 00:29:10 +0000 2012
>Originator:     Mikel Ward
>Release:        4.0
>Organization:
>Environment:
NetBSD beaker.endbracket.net 4.0 NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:20:10 PST 2007  builds@wb34:/home/builds/ab/netbsd-4-0-RELEASE/i386/200712160005Z-obj/home/builds/ab/netbsd-4-0-RELEASE/src/sys/arch/i386/compile/GENERIC i386
>Description:
I can run
    tput AF 1

to set my foreground color to red, but
    tput setaf 1

silently does nothing, and returns with exit status 0.

It seems
    tput setaf 0

does successfully set the foreground color to black, however.

I either want tput to not accept setaf at all, and return a non-zero exit status, or to have the same behavior as the AF attribute, since my understand is that they are equivalent.
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: "Mikel Ward" <mikel@mikelward.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/39883: tput support for setaf terminfo sequence is broken
Date: Sat, 8 Nov 2008 14:00:51 +1100

 Nothing obvious in the tput source, nor does setaf appear anywhere
 obvious in /usr/share/misc/termcap.

 Will see what tgetstr returns.

Responsible-Changed-From-To: bin-bug-people->jnemeth
Responsible-Changed-By: jnemeth@NetBSD.org
Responsible-Changed-When: Sat, 08 Nov 2008 11:04:08 +0000
Responsible-Changed-Why:
I responded and I'm working on it.


State-Changed-From-To: open->analyzed
State-Changed-By: jnemeth@NetBSD.org
State-Changed-When: Sat, 08 Nov 2008 11:04:08 +0000
State-Changed-Why:
tput is described as "terminal capability interface".  "terminal capability"
is the long form of "termcap"  tput works with termcap, not terminfo.  setaf
is not a vaild termcap capbility.  termcap capabilities are two characters
long.  It appears that tgetstr(3) et al simply truncate capabilities that
are longer then two characters.  Will consider modifying tput to give an
error when somebody asks for a capability that isn't two characters long.


State-Changed-From-To: analyzed->closed
State-Changed-By: roy@NetBSD.org
State-Changed-When: Thu, 04 Feb 2010 14:44:29 +0000
State-Changed-Why:
-current now has terminfo support and tput respects terminfo codes.


State-Changed-From-To: closed->analyzed
State-Changed-By: jnemeth@NetBSD.org
State-Changed-When: Thu, 04 Feb 2010 19:10:25 +0000
State-Changed-Why:
Just because something is fixed in -current does not mean it doesn't need
to be fixed on the branches.  PRs shouldn't be closed until the problem
is fixed on all relevant branches or it is determined that it is too
difficult.


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: jnemeth@NetBSD.org, mikel@mikelward.com
Subject: Re: bin/39883 (tput support for setaf terminfo sequence is broken)
Date: Sun, 14 Mar 2010 18:42:26 +0000

 On Thu, Feb 04, 2010 at 07:10:26PM +0000, jnemeth@NetBSD.org wrote:
  > Just because something is fixed in -current does not mean it doesn't need
  > to be fixed on the branches.  PRs shouldn't be closed until the problem
  > is fixed on all relevant branches or it is determined that it is too
  > difficult.

 This is very true; however, I don't think terminfo is going to be
 pulled up to -5 (let alone -4) and it's really not practical to try to
 handle terminfo codes some other way there. Even if someone wanted to
 spend time writing a translation table for terminfo capabilities,
 realistically they wouldn't be likely to ever get around to it.

 I suppose tput should exit 1 when asked for an unknown capability
 though; would fixing that be sufficient?

 -- 
 David A. Holland
 dholland@netbsd.org

From: jnemeth@cornerstoneservice.ca (John Nemeth)
To: David Holland <dholland-bugs@netbsd.org>, gnats-bugs@netbsd.org
Cc: mikel@mikelward.com
Subject: Re: bin/39883 (tput support for setaf terminfo sequence is broken)
Date: Sun, 14 Mar 2010 19:01:33 -0700

 On Mar 14,  6:42pm, David Holland wrote:
 } On Thu, Feb 04, 2010 at 07:10:26PM +0000, jnemeth@NetBSD.org wrote:
 }  > Just because something is fixed in -current does not mean it doesn't need
 }  > to be fixed on the branches.  PRs shouldn't be closed until the problem
 }  > is fixed on all relevant branches or it is determined that it is too
 }  > difficult.
 } 
 } This is very true; however, I don't think terminfo is going to be
 } pulled up to -5 (let alone -4) and it's really not practical to try to
 } handle terminfo codes some other way there. Even if someone wanted to
 } spend time writing a translation table for terminfo capabilities,
 } realistically they wouldn't be likely to ever get around to it.
 } 
 } I suppose tput should exit 1 when asked for an unknown capability
 } though; would fixing that be sufficient?

      That would be sufficient.  I seem to recall more discussion
 on the issue, but I guess it was on a mailing list.  I think the
 idea was that if somebody asked for a capability more then two
 letters long that tput would exit with an error.  The problem was
 that tgetstr() simply truncated to two characters, so "setaf" became
 "se" (standout end).

 }-- End of excerpt from David Holland

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: jnemeth@NetBSD.org
Subject: Re: bin/39883 (tput support for setaf terminfo sequence is broken)
Date: Sat, 29 May 2010 19:41:59 +0000

 On Mon, Mar 15, 2010 at 02:00:08AM +0000, John Nemeth wrote:
  >  } I suppose tput should exit 1 when asked for an unknown capability
  >  } though; would fixing that be sufficient?
  >  
  >       That would be sufficient.  I seem to recall more discussion
  >  on the issue, but I guess it was on a mailing list.  I think the
  >  idea was that if somebody asked for a capability more then two
  >  letters long that tput would exit with an error.  The problem was
  >  that tgetstr() simply truncated to two characters, so "setaf" became
  >  "se" (standout end).

 Like this? It seems to do the trick.

 Index: tput.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/tput/tput.c,v
 retrieving revision 1.19
 diff -u -p -r1.19 tput.c
 --- tput.c	21 Jul 2008 14:19:27 -0000	1.19
 +++ tput.c	29 May 2010 19:39:38 -0000
 @@ -105,7 +105,9 @@ main(int argc, char **argv)
  			break;
  		}
  		cptr = buf;
 -		if (tgetstr(p, &cptr))
 +		if (strlen(p) > 2)
 +			exitval = 1;
 +		else if (tgetstr(p, &cptr))
  			argv = process(p, buf, argv);
  		else if ((n = tgetnum(p)) != -1)
  			(void)printf("%d\n", n);


 -- 
 David A. Holland
 dholland@netbsd.org

From: jnemeth@CornerstoneService.ca (John Nemeth)
To: David Holland <dholland-bugs@netbsd.org>, gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/39883 (tput support for setaf terminfo sequence is broken)
Date: Tue, 1 Jun 2010 20:51:21 -0700

 On May 29,  7:41pm, David Holland wrote:
 } On Mon, Mar 15, 2010 at 02:00:08AM +0000, John Nemeth wrote:
 }  >  } I suppose tput should exit 1 when asked for an unknown capability
 }  >  } though; would fixing that be sufficient?
 }  >  
 }  >       That would be sufficient.  I seem to recall more discussion
 }  >  on the issue, but I guess it was on a mailing list.  I think the
 }  >  idea was that if somebody asked for a capability more then two
 }  >  letters long that tput would exit with an error.  The problem was
 }  >  that tgetstr() simply truncated to two characters, so "setaf" became
 }  >  "se" (standout end).
 } 
 } Like this? It seems to do the trick.
 } 
 } Index: tput.c
 } ===================================================================
 } RCS file: /cvsroot/src/usr.bin/tput/tput.c,v
 } retrieving revision 1.19
 } diff -u -p -r1.19 tput.c
 } --- tput.c	21 Jul 2008 14:19:27 -0000	1.19
 } +++ tput.c	29 May 2010 19:39:38 -0000
 } @@ -105,7 +105,9 @@ main(int argc, char **argv)
 }  			break;
 }  		}
 }  		cptr = buf;
 } -		if (tgetstr(p, &cptr))
 } +		if (strlen(p) > 2)
 } +			exitval = 1;

      This would simply mean that the user asked for a capabilty
 that the terminal doesn't have.  This may or may not be true.
 "exitval = 2;" would probably be better since that would indicate
 that the user did something wrong.  We may even want to consider
 something like:

 exit(2, "this program only supports termcap capabilities, not terminfo");

 } +		else if (tgetstr(p, &cptr))
 }  			argv = process(p, buf, argv);
 }  		else if ((n = tgetnum(p)) != -1)
 }  			(void)printf("%d\n", n);
 } 
 }-- End of excerpt from David Holland

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39883 CVS commit: [netbsd-4] src/usr.bin/tput
Date: Wed, 14 Nov 2012 20:25:31 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Wed Nov 14 20:25:31 UTC 2012

 Modified Files:
 	src/usr.bin/tput [netbsd-4]: tput.c

 Log Message:
 usr.bin/tput/tput.c				patch

 	Fix tput support for setaf terminfo sequence. PR#39883.
 	[jnemeth, ticket #1468]


 To generate a diff of this commit:
 cvs rdiff -u -r1.17 -r1.17.6.1 src/usr.bin/tput/tput.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39883 CVS commit: [netbsd-5] src/usr.bin/tput
Date: Tue, 27 Nov 2012 18:17:08 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Tue Nov 27 18:17:08 UTC 2012

 Modified Files:
 	src/usr.bin/tput [netbsd-5]: tput.c

 Log Message:
 usr.bin/tput/tput.c				patch

 	Fix tput support for setaf terminfo sequence. PR#39883.
 	[jnemeth, ticket #1822]


 To generate a diff of this commit:
 cvs rdiff -u -r1.19 -r1.19.4.1 src/usr.bin/tput/tput.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->closed
State-Changed-By: jnemeth@NetBSD.org
State-Changed-When: Thu, 29 Nov 2012 00:29:10 +0000
State-Changed-Why:
Pullups completed.  Thanks for the PR!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.