bug-bash
[Top][All Lists]
Advanced

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

BUG? Wrong BASH_LINENO for trap in compound command


From: Markus Laire
Subject: BUG? Wrong BASH_LINENO for trap in compound command
Date: Mon, 06 Mar 2006 20:14:59 -0000

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include
-I./lib   -g -O2
uname output: Linux Knoppix 2.6.12 #2 SMP Tue Aug 9 23:20:52 CEST 2005
i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.1
Patch Level: 0
Release Status: release

Description:
        In the included script, BASH_LINENO[0] within trap is allways the 
ending line
        of the enclosing compound command, instead of the line which caused
        the trap.
        
        Is this the intended behaviour, and if yes, is there any way to know 
within
        the trap the linenumber which caused the trap?

Repeat-By:
        Repeat by running this script.
            echo $BASH_VERSION
            mytrap() {
              echo "ERR @ ${BASH_LINENO[0]}"
            }
            trap mytrap ERR
            {
              false # <-- I want this linenumber
              true
            }  # <-- this line is reported
            while true ; do
              false # <-- I want this linenumber
              true
              break
            done # <-- this line is reported
            (
              trap mytrap ERR
              false # <-- I want this linenumber
              true
            )  # <-- this line is reported

--
Markus Laire




reply via email to

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