I'ld like to know if there any way to get the type of the terminal but get env("TERM").
tgetent(NULL, getenv("TERM"));
But if i execute my program with an empty env
env -i ./a.out
i wont be able to get the terminal type i need to use the termcap library.
Is there any way to find the terminal type with an empty env ?
You do not find the terminal environment, but rather, set it so that your applications will work properly. It should be set to correspond with the capabilities of the terminal your program runs in.
There are some special cases, such as cron
, where you do not have a terminal, but for some reason want to be able to use termcap (more likely, a termcap interface to a terminfo library, by the way). In ncurses, there are a few entries such as generic
, unknown
and dumb
which refer to terminals that cannot be used for full-screen mode.
Most (say 2/3 or more) of the terminal emulators in use today have a reasonable level of compatibility with DEC VT100's, so setting TERM
to vt100
"works". For a better fit, you need to know what the terminal does. Some people will for instance say to set it to xterm
, but that may not be good advice (ncurses FAQ Why not just use TERM set to "xterm"?).