bug-bash
[Top][All Lists]
Advanced

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

Re: Execution strange when get lines of the console in script with comma


From: Jonathan Nieder
Subject: Re: Execution strange when get lines of the console in script with command substitution and the rediretion of the stderr.
Date: Thu, 24 Nov 2011 13:29:32 -0600
User-agent: Mutt/1.5.21+46 (b01d63af6fea) (2011-07-01)

(+cc: help-bash, -cc: bug-bash, bcc: bug-bash)
Hi,

QGZ wrote:

>         $ cat abc.sh
>         #!/bin/bash
>         tput lines
>         echo $(tput lines)
[...]
>         $ ./abc.sh 2>/dev/null
>
>         We will get :
>         50
>         24

This is an ncurses question, not a "bash" question, so let's move to
the help-bash list.

The tput(1) manual does not describe how it gets access to the
terminal to read the number of lines.  Fortunately, from your example
we can deduce that tput checks if the standard output (file
descriptor 1) and standard error (file descriptor 2) streams are
terminals and communicates with the terminal using whichever one is a
tty.  Something like

        echo $(tput lines 2>/dev/tty)

might get your script working again.  A patch to the manual page from
the ncurses-bin package to clarify this would presumably be welcome.

>         I don't know why it is.  What is amazing is the number 24. 

That's the traditional height of an 80x24 terminal.

Hope that helps.

Regards,
Jonathan



reply via email to

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