On 12/14/11 4:13 AM, dethrophes@modt005 wrote: > 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
This is an interesting problem. The line number and source file name information is set when the function is read instead of when it's defined (defining a function is a command itself). Since the source command and the function redefinition are part of the compound command that is the `if' command's body, the entire if command is read, setting the initial function filename and line number information, before any of it is executed. That gets overwritten when the second file is sourced, and not restored when the function is redefined during the if command's execution. The difference between main1 and main2 is the fact that bash always reads an entire command before executing any of it, and the if statement is a compound command. I will have to see if the function definition can do a better job of carrying around the source file and line information, but that's a pretty significant change. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/