Re: help with bash functions Unix

From: Billy Patton (bpatton_at_ti.com)
Date: 12/16/04


Date: Thu, 16 Dec 2004 12:19:42 -0600

On Thu, 16 Dec 2004, Chris F.A. Johnson wrote:

> On Thu, 16 Dec 2004 at 16:55 GMT, Billy Patton wrote:
>> if i have function:
>>
>> func_a ()
>> {
>> printf " I'm in '%s'\n" how_do_I_get_function_name;
>> ...
>> }
>>
>> How do I get the function name.
>>
>> I'll be writing a lot of these, lots of cutting and pasting.
>> It will be VERY easy to forget to change the name of the function
>> nested within the function.
>> So how do I get the name?
>
> In bash, there is the variable, FUNCNAME:
>
> func()
> {
> printf "FUNCNAME = %s" $FUNCNAME
> }
>
>
> I have never needed it; why do you?

   abc ()
   {
     outdir=$OUTDIR/$FUNCNAME;

Just one way. For each task I will have a function by the same name It will
also be part of the output directory.

The more I can cut/paste without having to edit, the better off I am.

>
>
> --
> Chris F.A. Johnson http://cfaj.freeshell.org/shell
> ===================================================================
> My code (if any) in this post is copyright 2004, Chris F.A. Johnson
> and may be copied under the terms of the GNU General Public License
>

    ___ _ ____ ___ __ __
   / _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
  / _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
            /___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-patton@ti.com



Relevant Pages

  • Re: Stupid cat tricks - Anyone have other tricks?
    ... 2004-06-28, 13:25, Chris F.A. Johnson: ... It is still reading from stdin and writing to ...
    (comp.unix.shell)
  • Football for Baseball
    ... 193 Chris Simms ... 199 Rudi Johnson ... 225 Mike Peterson ... Marvin Harrison ...
    (rec.collecting.sport.football)
  • football for baseball
    ... Thing is we only collect cards of a few baseball players ... 193 Chris Simms ... 199 Rudi Johnson ... Marvin Harrison ...
    (rec.collecting.sport.baseball)
  • Re: To Many Errors!
    ... times but is being somewhat offset by the reduced debugging time. ... > of the problems searching the web, and there are MVP'S like Chris ... As long as Pocket PC application development is ... Writing an Application in No Time!!! ...
    (microsoft.public.dotnet.framework.compactframework)