mainThe GNU Bourne-Again SHell - Support: sr #109600, BASH_SOURCE[0] empty inside a...


sr #109600: BASH_SOURCE[0] empty inside a function when compiling with --disable-debugger

Submitter:  None
Submitted:  Mon 10 Dec 2018 09:21:33 AM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Wont Do
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup

Fri 21 Dec 2018 01:59:21 PM UTC, comment #3: 

The man page doesn't really cover features that can be compiled out of the shell. For instance, it describes arrays, even though the shell can be configured so they're not included. The documentation can only describe the default configuration as distributed.

Chet Ramey <chet>
Group administrator
Fri 21 Dec 2018 10:23:38 AM UTC, comment #2: 

Hello Mr. Ramey,

thank you very much for your answer!

Maybe the Bash Reference Manual could be adapted to reflect the fact that BASH_SOURCE is tied to the debugger feature?

Best wishes,
Andrej Gantvorg

Thu 20 Dec 2018 04:58:52 PM UTC, comment #1: 

Yes, it was a bug in bash-3.2 that that information leaked out when debugging support wasn't compiled in.

Chet Ramey <chet>
Group administrator
Mon 10 Dec 2018 09:21:33 AM UTC, original submission:  


the following snippet emits en empty string when bash is compiled with "--disable-debugger":


function fn {
        echo ${BASH_SOURCE[0]}


When compiling without this option, the script file name is emitted, as expected.

It used to work in bash-3.2.57.

This behaviour seems to go as far back as bash-4.0.38 (git commit 89a92869e56aba4e4cab2d639c00a86f0545c862).

Unfortunately, I could not bisect this any further because older versions refuse to compile on my Ubuntu 16.04.

Best wishes,
Andrej Gantvorg



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-20 chet StatusNone Wont Do

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code