Thread View: comp.unix.shell
2 messages
2 total messages
Started by viki
Thu, 18 Sep 2008 06:06
[bash] line number of function caller
Author: viki
Date: Thu, 18 Sep 2008 06:06
Date: Thu, 18 Sep 2008 06:06
17 lines
1727 bytes
1727 bytes
I use this function die in scripts, like this:
die() { echo >&2 "$*"; exit 100; }
...
cp from to || die Error
I wanted to print, in the die, the line number of calling line. Is
this possible ?
I have script name in $), do I have access to the stack of callers
line numbers ?
Is it possible to print stack of line numbers and function names
of all finctions in the function call stack ?
Thanks
VM
crossposted: gnu.bash,comp.unix.shell
Re: [bash] line number of function caller
Author: pk
Date: Thu, 18 Sep 2008 09:59
Date: Thu, 18 Sep 2008 09:59
16 lines
1423 bytes
1423 bytes
On Thursday 18 September 2008 08:06, viki wrote:
> I use this function die in scripts, like this:
>
> die() { echo >&2 "$*"; exit 100; }
> ...
> cp from to || die Error
>
> I wanted to print, in the die, the line number of calling line. Is
> this possible ?
> I have script name in $), do I have access to the stack of callers
> line numbers ?
> Is it possible to print stack of line numbers and function names
> of all finctions in the function call stack ?
man bash, BASH_LINENO and related variables.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads