

Ctypes.sh, a foreign function interface for bash - JoshTriplett
https://github.com/taviso/ctypes.sh/wiki#resubmit

======
eeZi
rundll32.exe!

Cool stuff. Reminds me of iPython and xonsh.

[http://ipython.org/](http://ipython.org/)
[http://xonsh.org/](http://xonsh.org/)

------
zurn
Nice. The plugin nature of it does raise the bar a little on using it. Looking
forward to the day I can apt-get this in Debian and Ubuntu!

------
leni536
I didn't know this "enable -f" feature of bash, it's certainly handy. What are
some other interesting binary bash plugins?

I really like this one, most certainly one would use it to build specialized
bash libraries that wraps all the ugly stuff. Like a speedy sqlite3 bash
library that keeps a database connection open and you can build up
transactions by multiple bash commands, it would be a nice alternative to
calling sqlite3 multiple times or building a huge sql statement and then
calling it once.

~~~
imglorp
Probably a great source of security holes, if nothing else :-)

Here's a writeup of how to do plugins: [http://www.drdobbs.com/shell-corner-
bash-dynamically-loadabl...](http://www.drdobbs.com/shell-corner-bash-
dynamically-loadable-b/199102950)

I went to school with Chet in the late 80's and never knew about this feature
until today. Looks like fun.

------
buserror
Thats a very cool hack! I personally use 'tcc -run' to call into .so's from
the shell, but it's quite limited as far as interfacing back to a shell..

------
rurban
I started porting it to non-linux systems and would appreciate bsd testers for
my version. mingw/cygwin maybe also. see the first issue on gh.

~~~
rurban
Thanks to cemeyer freebsd is done. I've added now darwin and potential windows
(cygwin+mingw) support. Just need to check how to link to bash on windows,
because windows cannot link with unresolved symbols. Had no time to recompile
bash on windows yet.

------
mzs
I had no idea you could do this sort of stuff, it honestly scares me a bit,
but is cool, kudos.

FWIW you can get away with a lot from sh with the help of perl (arbitrary
syscalls) and debuggers (like gdb, breakpoint and change return values or just
call any function). In solaris it's particularly easy with truss and the p*
commands.

------
digi_owl
Getting a bit of a C64 vibe from this...

------
anon3_
Very interesting!

For bash or for POSIX shell? Why not just be POSIX compliant so it works
everywhere?

~~~
creshal
Because it's a binary plug-in to bash, not a shell script, and I don't think
POSIX has any mechanism for those.

------
Adapt
Reminds me of TempleOS.

[https://www.youtube.com/watch?v=ptGpy5NDplM](https://www.youtube.com/watch?v=ptGpy5NDplM)

~~~
anon3_
I think the similarity you're correlating is memory addresses. You see this a
lot if you go into C, especially if you're debugging.

If you think memory addresses are cool, check out GDB + Linux Kernel and how
it allows you to examine data structures:
[https://wiki.ubuntu.com/Kernel/KernelDebuggingTricks](https://wiki.ubuntu.com/Kernel/KernelDebuggingTricks)

