🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #4019

[bash] line number of function caller

#4019
From: viki
Date: Thu, 18 Sep 2008 06:06
17 lines
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
Technical Details
Message-ID: <3dff4cbc-52df-4792-b703-cf62866eccfb@i76g2000hsf.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!i76g2000hsf.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1012a6,15fcc8b350a04824,start
X-Google-Thread: 1054c0,15fcc8b350a04824,start
X-Google-Attributes: gid1012a6,gid1054c0,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!i76g2000hsf.googlegroups.com!not-for-mail
From: viki <vikimun@gmail.com>
Newsgroups: comp.unix.shell,gnu.bash
Subject: [bash] line number of function caller
Date: Wed, 17 Sep 2008 23:06:29 -0700 (PDT)
Organization: http://groups.google.com
Lines: 17
Message-ID: <3dff4cbc-52df-4792-b703-cf62866eccfb@i76g2000hsf.googlegroups.com>
NNTP-Posting-Host: 192.116.242.217
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1221717989 28301 127.0.0.1 (18 Sep 2008 06:06:29 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 18 Sep 2008 06:06:29 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: i76g2000hsf.googlegroups.com; posting-host=192.116.242.217; 
 posting-account=S5KW3QoAAADxg-ehGfpYWmOQFZ9e25Pw
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe)