On Linux I want to know the number of lines and columns of my working terminal. When on the command line I call by hand the system variables $LINES and $COLUMNS, I get the right answers.
When I try to do the same from a program written in Gnat Ada 2005 (Year 2010) using the specialized package Ada.Environment_Variables, as in the following code called from the same terminal, I get no answer for COLUMNS and LINES as if the corresponding system variables do not exist (I get a correct answer for PATH).
with Ada.Environment_Variables; use Ada.Environment_Variables;
with Ada.Text_Io; use Ada.Text_Io;
procedure Print_Env is
begin
Put_Line("Columns : " & Value("COLUMNS"));
Put_Line("Lines : " & Value("LINES"));
Put_Line("Path : " & Value("PATH"));
end Print_Env;
I would like to understand the reasons of this behavior. Are there different kinds of system variables in Linux ? Those as HOME, PATH whose values depend only on the user session and those as LINES, COLUMNS defined for each used terminal. Is there a way in Ada to overcome this limitation ?
Partager