help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Execution strange when get lines of the console in scrip


From: QGZ
Subject: Re: [Help-bash] Execution strange when get lines of the console in script with command substitution and the rediretion of the stderr.
Date: Fri, 25 Nov 2011 13:00:07 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

Thank you very much.  
This is my first time using the email-list, and I'm so lucky that you give me
so detail a explanation that helps a lot.
Thank you once again!


On Thu, Nov 24, 2011 at 01:29:32PM -0600, Jonathan Nieder wrote:
>Date: Thu, 24 Nov 2011 13:29:32 -0600
>From: Jonathan Nieder <address@hidden>
>To: QGZ <address@hidden>
>Cc: address@hidden
>Subject: Re: Execution strange when get lines of the console in script with
> command substitution and the rediretion of the stderr.
>
>(+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]