bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tput returns wrong value?


From: Thomas Dickey
Subject: Re: tput returns wrong value?
Date: Fri, 22 May 2009 10:23:33 -0400 (EDT)

On Fri, 22 May 2009, address@hidden wrote:

Dear maintainers of ncurses,

recently i discovered a strange behavior of tput showing by the following code 
example.

$cat testscript
tput cols
i=$( tput cols )
echo $i

$./testscript
109
109

$./testscript 2> /dev/null
109
80


As you can see the variable $i has the wrong value if the stderr chanel is 
redirected. Maybe this behavior is intended. I found it rather annoying and 
would know if this is correct.
At first i thought there is something wrong with bash but since it also fails 
on zsh i am writing you :-)

I tested it on bash 3.2 and zsh 4.3.9

To get the screensize, ncurses needs a file descriptor which is
connnected to the terminal.  Historically, stdout can be redirected
(so it's not necessarily used for this purpose).  So ncurses uses
stderr to obtain the screensize.

If stderr isn't connected to a terminal, ncurses will return the
values from the terminal description.


Thanks in advance for thinking about it!
Sebastian

P.S.
It only occurs when you put it in a file and execute the script:

$ tput cols; foo=$( tput cols ) ; echo $foo 2> /dev/null
109
109

See.. it works. So it seems to me that 80 is kind of a default value.
--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss 
für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02


_______________________________________________
Bug-ncurses mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-ncurses


--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]