Re: ksh function names
From: Jean-Marc Monnez (monnez.jean-marc_at_AGORA.MSA.FR)
Date: 03/14/05
- Previous message: Holger.VanKoll_at_SWISSCOM.COM: "Re: Identifying a resorce which causes a lock on a mutex."
- In reply to: Fred.Bateman_at_usdoj.gov: "Re: ksh function names"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 14 Mar 2005 11:01:12 +0100 To: aix-l@Princeton.EDU
Bingo !
The syntax with or without parenthesis makes it work differently, at least
for $0 !
-> with the keyword "function myfunc1", $0 returns function name myfunc1
-> with the parenthesis "myfunc2()", $0 returns the global script name
myscript.
I previously thought that both syntaxes were totally equivalent, as said in
the O'Reilly "Learning the Ksh".
Thanks a lot.
Regards.
-- JMM
-----------------------------
Jean-Marc MONNEZ
MSA / AGORA / ATD
monnez.jean-marc@agora.msa.fr
-----------------------------
"Fred.Bateman@usdoj.gov" a écrit :
> Try the following:
>
> function myfunc1
> {
> echo function name: $0
> }
>
> myfunc2()
> {
> echo function name: $0
> }
>
> myfunc1
> myfunc2
>
> -----Original Message-----
> From: aix-l@Princeton.EDU [mailto:aix-l@Princeton.EDU]On Behalf Of
> monnez.jean-marc@AGORA.MSA.FR
> Sent: Thursday, March 10, 2005 10:40 AM
> To: aix-l@Princeton.EDU
> Subject: Re: ksh function names
> Importance: Low
>
> "typeset +f" prints all function names, so it can't give the current
> function.
>
> Thanks anyway.
> Regards
>
> -- JMM
>
> -----------------------------
> Jean-Marc MONNEZ
> MSA / AGORA / ATD
> monnez.jean-marc@agora.msa.fr
> -----------------------------
>
> "Fred.Bateman@usdoj.gov" a écrit :
>
> > No guarantees:
> >
> > #!/bin/ksh
> > myfunc()
> > {
> > func=`typeset +f`
> > echo var: $0 $func
> > }
> >
> > -----Original Message-----
> > From: aix-l@Princeton.EDU [mailto:aix-l@Princeton.EDU]On Behalf Of
> > monnez.jean-marc@AGORA.MSA.FR
> > Sent: Thursday, March 03, 2005 5:30 AM
> > To: aix-l@Princeton.EDU
> > Subject: ksh function names
> > Importance: Low
> >
> > hello all,
> >
> > Inside a ksh function, is it possible to use a standard variable that
> > returns the function name ?
> >
> > In some old ksh implementations the positional $0 contained this
> > function name, but in recent ksh versions it returns the global script
> > name.
> >
> > #!/bin/ksh
> > myfunc()
> > {
> > --> a variable that automatically contains "myfunc" ?
> > }
> >
> > Regards
> > -- JMM
> >
> > -----------------------------
> > Jean-Marc MONNEZ
> > MSA / AGORA / ATD
> > monnez.jean-marc@agora.msa.fr
> > -----------------------------
- Previous message: Holger.VanKoll_at_SWISSCOM.COM: "Re: Identifying a resorce which causes a lock on a mutex."
- In reply to: Fred.Bateman_at_usdoj.gov: "Re: ksh function names"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|