Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, does anybody have an idea, how to replace $0 (positional parameter, which stores function name inside function) within function within a shell(ksh8 script ? f_somefunc () { echo $0 ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    5

    Unhappy Replace $0 within shell function

    Hello,

    does anybody have an idea, how to replace $0 (positional parameter, which stores function name inside function) within function within a shell(ksh8 script ?

    f_somefunc () {

    echo $0 #returns f_somefunc
    %#$%#$ ="aaaa" #here is hint needed how to replace $0 value with aaaa
    echo $0 #so in this step the echo returns aaaa

    }

    thank you very much
    hm

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    The first question that comes to my mind is "Why?". $0 is a special variable. Even if you can change its value (which I'm not sure if you can), it makes your code more confusing to understand in the future, and I'm not sure that there's any point.
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    5
    well, the main issue is that i have to source to my script another script, which i cant modify nor reject, as it is part of more global solution, and sourced script functions then use $0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...