You don't make executables out of functions. You must have a main to make an executable. main() itself is a function, but it's a special function. An executable is built with a assembly language module often called crt0.o that gets the ball rolling, but it must have a main() to call. An executable will always have a main(). If you want to call an executable from ksh, you must proceed as I showed above. If you want to add one of your functions into the ksh executable, that is different.
When I said that ksh-92 could make use of a function that was dymanically loaded into it, I didn't mean to imply that ksh-88 could as well. Let me be more plain:
This cannot be done with ksh-88.
But with ksh-92, it is possible, although I do not know exactly how to do this.
The New KornShell Command and Programming Language by Morris I Bolsky and David G Korn states:
Quote:
In addition, on systems that have the ability to link in code at runtime, the builtin command can be used to add code libraries and built-in commands. The description of how to create these commands is outside the scope of this book.
At other places in the book I can see that you use the -f option to builtin to specify a path of a shared library which must contain a function named b_
name for each builtin named
name that you want to add. But I have no idea how ksh will pass arguments to that function. Since variables can be integer or strings there must be some information on the structure of the variable somewhere.
I suppose that I would start by downloading the source code to ksh and studying it to determine exactly how it loads and invokes functions. I'm going to guess that you're not clear on how to create a shared library. This is described on the ld man page, but I would also suggest that you obtain a copy of
HP-UX Linker and Libraries User's Guide and read it as well.
I don't want to be snotty here, but my sense is that you're biting off more than you can chew. But if I'm wrong and you get this to work, please post again and explain how you did it. I'd like to know how to do this myself.