Re: ksh function names

From: Jean-Marc Monnez (monnez.jean-marc_at_AGORA.MSA.FR)
Date: 03/14/05

  • Next message: self help: "generate md5"
    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
    > > -----------------------------

    
    


  • Next message: self help: "generate md5"

    Relevant Pages

    • Re: Is there a better/simpler way to filter blank lines?
      ... expression from surrounding syntax. ... surrounding syntax with the exception when there are already enclosing ... So parenthesis are tied to generator expression syntax. ...
      (comp.lang.python)
    • Re: Confusion with bindings - scheme newbie
      ... the syntax of LET is ... a LET that has only one binding looks like ... [(sos y z)] ... Now thats a lot of parenthesis to deal with. ...
      (comp.lang.scheme)
    • Re: About those parenthesis....
      ... > I like parenthesis and prefix from beginning. ... I have programmed with Lisp-like semantics using the fsyntax. ... The fnotation has no nice way to denote the empty list, ... So, in summary, fis an abomination that rightfully deserves ...
      (comp.lang.lisp)
    • Re: print(true and true) #=> the parenthesis issue
      ... The parenthesis have been discussed before, ... out why the parser gets confused here. ... In the second case the parser seems to be expecting ... obscure syntax that requires this behavior. ...
      (comp.lang.ruby)