ctypes.sh
ctypes.sh copied to clipboard
Port to ZShell
Great tool. Would be nice to have also in zsh.
A better idea would be making it shell-independent, if possible.
It looks like zsh does have a zmodload
function, which sounds like it could work with ctypes.sh.
Let's investigate if this is possible.
Unfortunately making it shell independent is not possible (ctypes.sh is a plugin, not a script), and needs loadable module support to work.
Unfortunately making it shell independent is not possible (ctypes.sh is a plugin, not a script), and needs loadable module support to work.
It may be possible to have a single .so loadable by both module systems, if there's nothing explicitly incompatible about the interfaces. :-)
Here is an example zsh module: https://sourceforge.net/p/zsh/code/ci/master/tree/Src/Modules/attr.c (in a directory full of modules).
I advise against a single .so loadable by both zsh and bash, since that may turn as not maintainable. One can export common functions in a separate .o to be compiled in two different modules. Such an approach may also make it simple to port to other shells.
why not make it a shell independent proper executable? something like:
dlopen blah.so & handle=$!
# listens for control signals $somehow
dlcall $handle somefunction int:1337
# tells dlopen to do stuff
kill $handle
# exits dlopen (it should also exit when losing its parent, just in case)
also, @jaromil, what you're looking for is called a) "libdl.so" and b) "LuaJIT". and btw the language is called "Lua". spanish proper noun (moon), not an abbreviation.