Results 1 to 4 of 4
Hi,
suppose i have a script in which 3 functions are gettting called, now normally i would have to source the file in which these functions are defined, instead i ...
- 06-10-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 4
Function sourcing in a shell script
Hi,
suppose i have a script in which 3 functions are gettting called, now normally i would have to source the file in which these functions are defined, instead i want to write one script which at the runtime will look in my script to see how many functions are getting called and then would automatically source them at runtime.
i also want to maintain the hierarchy of calling the function..
does anyone have any approach abt it ?
thanks
- 06-10-2008 #2Just Joined!
- Join Date
- Jun 2008
- Posts
- 39
Will you post the script and the functions?
- 06-10-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 4
Hi, thanks for reply, i am not talking abt any particular script, what i have written is a problem i have to approach, the function loader script would be generic and would work with any shell script which internally wants to call some function which it didnt source first.
Now my first problem is that how to find out in a given script what are the functions being called. just doing grep for "$(" isnt enough to find out where are the functions in the script, thats why i was looking for some different solution dealing with how script internally calls other function at runtime, i lack an in depth idea of what happens at runtime when a shell script gets executed..
- 06-10-2008 #4Just Joined!
- Join Date
- Jun 2008
- Posts
- 39
Can you explain what you mean by "how to find out in a given script what are the functions being called"? Can you explain what you mean by "normally i would have to source the file"? Will you give an example?
If you have a script, and you run the script, then you can find out what was called by using the shell command "history 3".


Reply With Quote