Hacker News new | past | comments | ask | show | jobs | submit login

This seems like a good time to mention my (ridiculous) project, a ctypes module for bash.

https://github.com/taviso/ctypes.sh/wiki

There are some little demos here:

https://github.com/taviso/ctypes.sh/tree/master/test

I even ported the GTK+3 Hello World to bash as a demo:

https://github.com/taviso/ctypes.sh/blob/master/test/gtk.sh




I found ctypes.sh to be legitimately useful for managing resources in nix-shell.

E.g. flock a lock file and set CLOEXEC so that subprocesses don't hold the lock open after the shell exits.

E.g. Use memfd_create to create a temp file and write a key. Then pass /proc/$$/fd/$FD to programs that need the key as a file. When the shell exits, the file can no longer be opened.

You can do similar things with traps, but they aren't guaranteed to execute, whereas these OS primitives will always be cleaned up.


"ctypes.sh is a bash plugin that provides a foreign function interface directly in your shell."


This is so awesome. I need to play with this.


This is MARVELOUSLY ridiculous and I love it. Thanks for sharing your work.




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

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

Search: