Hacker News new | past | comments | ask | show | jobs | submit login
Ctypes.sh, a foreign function interface for bash (github.com/taviso)
98 points by JoshTriplett on July 28, 2015 | hide | past | favorite | 14 comments



rundll32.exe!

Cool stuff. Reminds me of iPython and xonsh.

http://ipython.org/ http://xonsh.org/


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!


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.


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

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


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


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.


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.


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.


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



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


Very interesting!

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


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


Probably POSIX shell doesn't specify any plugin API.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: