ctypes.sh icon indicating copy to clipboard operation
ctypes.sh copied to clipboard

Port to ZShell

Open jaromil opened this issue 8 years ago • 5 comments

Great tool. Would be nice to have also in zsh.

jaromil avatar Mar 11 '16 09:03 jaromil

A better idea would be making it shell-independent, if possible.

tsudoko avatar Jun 20 '16 18:06 tsudoko

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.

taviso avatar Jul 19 '16 15:07 taviso

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).

cemeyer avatar Jul 19 '16 16:07 cemeyer

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.

jaromil avatar Jul 24 '16 07:07 jaromil

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.

nonchip avatar Dec 11 '17 22:12 nonchip