bug-bash
[Top][All Lists]
Advanced

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

Execution strange when get lines of the console in script with command s


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

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux QGZ 3.0.0-1-686-pae #1 SMP Sat Aug 27 16:41:03 UTC 2011 
i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 4.1
Patch Level: 5
Release Status: release



Description:
        When I use "tput lines" to get the lines of console, it works, and also 
works in a script.
        And if execute the command in a script with the command substitution, 
it works well too.
        But if execute the script with the redirection "2>/dev/null", it won't 
work well.
        I'm not sure whether it is a bug or just my lack of some required 
knowledge.
        Please see one example below.

Repeat-By:
        $ cat abc.sh
        #!/bin/bash
        tput lines
        echo $(tput lines)

        If execute the script with the content above, it is all right like :
        $ ./abc.sh
        50
        50

        But if execute the script like this :
        $ ./abc.sh 2>/dev/null

        We will get :
        50
        24

        I don't know why it is.  What is amazing is the number 24. 
        The number would never change no matter how I resize the console or 
other terminals.

        It also happens when a line of command in the script like "tput lines | 
cat".

        I haven't see the source code of BASH.  I'm very sorry for having no 
good advice about this.
        And also sorry for my poor English. @_@





reply via email to

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