[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with overridden functions and BASH_SOURCE Array
From: |
dethrophes |
Subject: |
Problem with overridden functions and BASH_SOURCE Array |
Date: |
Wed, 14 Dec 2011 10:13:15 +0100 (CET) |
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/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall
uname output: Linux modt005 2.6.38-13-generic #52-Ubuntu SMP Tue Nov 8 16:48:07
UTC 2011 i686 i686 i386 GNU/Linux
Machine Type: i686-pc-linux-gnu
Bash Version: 4.2
Patch Level: 8
Release Status: release
Description:
Problem with overridden functions having wrong source file name in
BASH_SOURCE Array
see example in Repeat-By section
Repeat-By:
sourced_file.sh
function test_function {
echo 1
echo "${BASH_SOURCE[0]}(${BASH_LINENO[0])${FUNCNAME[0]}"
}
main1.sh
source sourced_file.sh
function test_function {
echo 2
echo "${BASH_SOURCE[0]}(${BASH_LINENO[0])${FUNCNAME[0]}"
}
test_function
main2.sh
if true; then
source sourced_file.sh
function test_function {
echo 2
echo
"${BASH_SOURCE[0]}(${BASH_LINENO[0])${FUNCNAME[0]}"
}
test_function
fi
running main1.sh you get as expected
2
main.sh(4)test_function
running main2.sh you get unexpectedly
2
sourced_file.sh(4)test_function
- Problem with overridden functions and BASH_SOURCE Array,
dethrophes <=