Why is there both setf/setb and setaf/setab in tput? Why is there both setf/setb and setaf/setab in tput? unix unix

Why is there both setf/setb and setaf/setab in tput?


Why isn't there just setf/setb and they always set the foreground and background colorsare actually two questions!

The first part, why there are ANSI and non-ANSI terminal commands takes too long to exaplin, and it's unnecessary as the history is quite well explained on Wikipedia.

The second part could perhaps be freely rephrased to "what's the difference?" or "what can I do about it?".

Difference:ANSI type terminals use another mapping between colour number and colours than non-ANSI terminals. For example, the code for yellow on one would be cyan on the other. There are simply two different mapping tables. Those things are described quite well on Wikipedia.

What you can do about it:Discover which type of terminal you have, and use corresponding command.Or modify your termcap.None of these solutions are fully generic though, unfortunately.