BASH_SOURCE[1] should contain the name of the calling source file. BASH_SOURCE (eg: $BASH_SOURCE[0]) contains the current source file, and that's the file containing the function.
I could be wrong though, but her's what I did: file: tst ---------- #/bin/bash . $(dirname $0)/tst.1 . $(dirname $0)/tst.2 function tst1 () { test_func } test_func tst1 tst2 tst3 --------- file tst.1 -------- #!/bin/bash function test_func () { echo "${BASH_SOURCE[1]}:${FUNCNAME[1]}" } function tst3 () { test_func } ------- file tst.2 -------- function tst2 () { test_func } ------------ When running the tst script this is the output $ bash tst tst:main tst:tst1 ./tst.2:tst2 ./tst.1:tst3 -- BASH_SOURCE is not correct https://bugs.launchpad.net/bugs/318678 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs