5 ms·
This seems like a good time to mention my (ridiculous) project, a ctypes module for bash. https://github.com/taviso/ctypes.sh/wiki https://github.com/taviso/ct
by taviso 7y ago
This seems like a good time to mention my (ridiculous) project, a ctypes module for bash.
https://github.com/taviso/ctypes.sh/wiki https://github.com/taviso/ctypes.sh/wiki
There are some little demos here:
https://github.com/taviso/ctypes.sh/tree/master/test 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 https://github.com/taviso/ctypes.sh/blob/master/test/gtk.sh
- bokchoi 7y agoThis is so awesome. I need to play with this.
- donpdonp 7y ago"ctypes.sh is a bash plugin that provides a foreign function interface directly in your shell."
- singron 7y agoI 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.
- valenciarose 7y agoThis is MARVELOUSLY ridiculous and I love it. Thanks for sharing your work.