COLUMNS
and LINES
are set by the shell, but not exported, which means that
they are not added to the environment of subsequently executed commands.
(To verify that, examine the output of /usr/bin/env
: it will show PATH
and USER
, but not COLUMNS
and LINES
.)
In the bash shell, you can call export VAR
to mark a variable for export.
Alternatively, see Getting terminal width in C? for various ways to obtain the terminal width and height programmatically.