From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eros.uknet.ac.uk ([192.91.199.2]) by archone.tamu.edu with SMTP id <45331>; Thu, 19 Mar 1992 07:40:39 -0600 Received: from ibmpcug.co.uk by eros.uknet.ac.uk with UUCP id <14622-0@eros.uknet.ac.uk>; Thu, 19 Mar 1992 13:40:17 +0000 Received: by ibmpcug.co.uk (smail2.5) id AA02384; 19 Mar 92 13:25:10 GMT (Thu) X-Phone-Work: +44 81 863-1191 X-Fax-Work: +44 81 863-6095 X-Favourite-Colour: black, of course. In-Reply-To: <9203191254.AA02417@dahlie.techfak.uni-bielefeld.de> Organization: The IBM PC User Group, UK. X-Mailer: Mail User's Shell (7.1.2 7/11/90) To: rc@archone.tamu.edu Subject: Re: an improvement(?) suggestion and a question Message-Id: <9203191325.AA02380@ibmpcug.co.uk> Date: Thu, 19 Mar 1992 07:25:09 -0600 From: Matthew Farwell In article <9203191254.AA02417@dahlie.techfak.uni-bielefeld.de> malte@techfak.uni-bielefeld.de writes: >in rc's man page it says that $0 is set to name of the function during its >execution, so a naive thought came to my mind: > > fn sighup sigint { > echo $progname was killed by $0 | mail somebody > exit 2 > } > >But this does not work since $0 when catching a signal is the name of >of the function rc was currently working on. > >To change this, I have two suggestions: > 1) Change the signal handler to place the signals name in $0 > and allow $* to be referenced with negative indices, with > $*(-1) evaluating to the name of the function the present > function was called from, $*(-2) ... > >This is a more general solution, or > > 2) Introduce a new special variable $signal which evaluates to > the name of the most current signal, so that the above example > will read > ... > echo $progname was killed by $signal | mail somebody > ... Or set $1 inside a signal handler to the name of the signal sent to the function, ie fn sigint sighup { echo $0 killed by signal $1 } Dylan. -- re-invented wheels are often square -- Henry Spencer