Solved sharing a library of shell functions

August 28, 2011 at 10:28:22
Specs: Windows XP
I have a requirement of sharing a set of library functions to different scripts in Korn shell.
I know one way to do this call the library function script/file using source command or '. ' operator.
is this ideal way to do so? or export -f will be handy or even I read about FPATH.
Can some one explain whats is the advantages or shortcomings of these different ways?
especially, calling this cause any issue while running multiple instance or different parent scripts that are using this library simultaneously?

See More: sharing a library of shell functions

Report •

#1
August 28, 2011 at 14:13:46
✔ Best Answer
Perhaps this link will be helpful:

http://www.computing.net/answers/un...


Report •

#2
August 28, 2011 at 20:48:57
Thanks Nails! for the post your referred. It was usuful. I have further question,

I would like to source at the same time, can I use typeset -fu options for the functions in the library so that only used functions will get loaded on need basis ( If I understood this concept correctly, dynamic binding ? )

Also when I source functions like this across many parent scripts, will they cause any issue if they run simultaneously? ( I asked this in my origional question )

Thanks in advance!!


Report •

#3
August 29, 2011 at 22:23:09
The idea of autoload (typeset -fu) is that a function is read in only when it needs to be executed instead of each time a korn shell is invoked. (not every bash shell supports typeset -fu).

>Also when I source functions like this across many parent scripts, will they cause any >issue if they run simultaneously? ( I asked this in my origional question )

I don't think so. Scripts run simulataneously by definition means they are running in different shells.



Report •
Related Solutions


Ask Question