Bug 214709 - tput in 10,11,12 is unable to set terminal colors
Summary: tput in 10,11,12 is unable to set terminal colors
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-21 16:59 UTC by Julian Elischer
Modified: 2021-02-26 17:18 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Elischer freebsd_committer freebsd_triage 2016-11-21 16:59:02 UTC
Tput doesn't do most of the things it's expected to do
leaving  you with no way to set bold or color from a script.

this breaks all scripts that use color for errors coming up from freebsd 8 or earlier, where it worked.

example 

tput setaf 1

should set the text to red, which it does on freebsd 4,5,6,7 and 8
(I don't have 9)
 and does not work on 10,11,12

tput setaf 1 |od -c shows that it puts out SOME codes and then fails.
Comment 1 Thomas E. Dickey 2016-11-22 01:57:06 UTC
FreeBSD tput uses termcap names (not the ncurses application).  You may have installed the ncurses (terminfo-based) port on the other systems.

Try

    #!/bin/sh
    for n in 1 2 3 4 5 6 7
    do
    tput AF $n
    echo color$n
    done
Comment 2 Jonathan de Boyne Pollard 2016-12-31 07:47:32 UTC
This appears to be the same as bug #210858.
Comment 3 Thomas E. Dickey 2016-12-31 12:07:32 UTC
You might find this helpful:

http://invisible-island.net/ncurses/man/tput.1.html#h2-HISTORY
http://invisible-island.net/ncurses/man/tset.1.html#h2-HISTORY

Since the premise for the bug report is incorrect, it should be closed.
Comment 4 Hiren Panchasara freebsd_committer freebsd_triage 2016-12-31 20:10:27 UTC
Julian,

Can you please comment?
Comment 5 Julian Elischer freebsd_committer freebsd_triage 2017-01-03 16:02:57 UTC
After reading more I came to the conclusion that my bug is misnamed and the problem is that FreeBSD uses what has become a less and less used variant of tput.
Ironically we actually have the *OTHER* tput in our sources as well.
(in the ncurses sources).
To me it seems odd that we can't get both names sets understood, and it's most annoying when scripts from elsewhere don't work on FreeBSD. I'd rather have a more standard tput, but at least it's not as bada s I had thought because I couldn't get ANY colors, but the example above at least gives me that.

I think we should follow netBSD and switch tputs.

but I'm sure it's more complicated than that.
Comment 6 Thomas E. Dickey 2017-01-03 21:32:49 UTC
Sure - it's more complicated:

- There's at least one case where there's a termcap name which corresponds to a different feature in terminfo.  Otherwise, ncurses might just have accepted both/either depending on the platform.

- NetBSD chose to write their own tput (though they're using a copy of the terminal database from ncurses).  You can take it for granted that NetBSD's tput will be different in some way from ncurses.
Comment 7 Jan Beich freebsd_committer freebsd_triage 2021-02-26 17:18:46 UTC
FreeBSD >= 14 defaults to terminfo. Both "tput setaf 1" and "tput AF 1" will work.
https://cgit.FreeBSD.org/src/commit/?id=61f66a1f4403fded9aae14d890ad96914a3c0bc1
https://cgit.FreeBSD.org/src/commit/?id=2a50a9de8340f08bd876e9e5993332ae14376f80