Reputation: 2866
I have a simple function that I'll be using heavily in my script. For improved user ability to follow where an error occurs, I'd like to output the line of the script that pulled the function into the warning I'll echo.
Another option might be including the function that called this function as it will typically be called by another function.
Is that something I can do easily within the function?
Upvotes: 0
Views: 70
Reputation: 26602
This echo gives parent file/function/line number :
echo "${BASH_SOURCE[1]}:${FUNCNAME[1]}:${BASH_LINENO[0]}"
Upvotes: 1