🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #4020

Re: [bash] line number of function caller

#4020
From: pk
Date: Thu, 18 Sep 2008 09:59
16 lines
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.
Technical Details
Message-ID: <gat8od$k0q$1@aioe.org>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!aioe.org!not-for-mail
References: <3dff4cbc-52df-4792-b703-cf62866eccfb@i76g2000hsf.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1012a6,15fcc8b350a04824
X-Google-Thread: 1054c0,15fcc8b350a04824
X-Google-Attributes: gid1012a6,gid1054c0,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!aioe.org!not-for-mail
From: pk <pk@pk.invalid>
Newsgroups: comp.unix.shell,gnu.bash
Subject: Re: [bash] line number of function caller
Followup-To: comp.unix.shell
Date: Thu, 18 Sep 2008 11:59:44 +0200
Organization: Not organized
Lines: 17
Message-ID: <gat8od$k0q$1@aioe.org>
References: <3dff4cbc-52df-4792-b703-cf62866eccfb@i76g2000hsf.googlegroups.com>
NNTP-Posting-Host: qNX0WN7YDp2hCthrBS6wOg.user.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
X-Complaints-To: abuse@aioe.org