taviso / ctypes.sh

A foreign function interface for bash.
MIT License
2.06k stars 92 forks source link

Port to ZShell #31

Open jaromil opened 8 years ago

jaromil commented 8 years ago

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

tsudoko commented 8 years ago

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

taviso commented 8 years ago

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.

cemeyer commented 8 years ago

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

jaromil commented 8 years ago

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.

nonchip commented 6 years ago

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.