4 ms·
It's a funny trick, but you could probably also use setjmp and longjmp with ctypes.sh :-) https://github.com/taviso/ctypes.sh https://github.com/taviso/ctypes.
by taviso 3y ago
It's a funny trick, but you could probably also use setjmp and longjmp with ctypes.sh :-)
https://github.com/taviso/ctypes.sh https://github.com/taviso/ctypes.sh
- tetromino_ 3y agoGreat heavens! I assumed at first that your "dlopen" was a separate executable, but you are implying you allow calling arbitrary C functions within the memory space of the bash process itself!?
- taviso 3y agoYes, exactly... :) You can also create callbacks (i.e. function pointers to bash code) that you can pass to qsort() or bsearch()... or pthread_create? That last one was a joke, I mean, you probably could but I don't know what would happen - I don't think bash is reentrant :)
- lanstin 3y agoWow, I thought the original article was awful tho good, then I saw the lseek goto which seems much worse, then I see this dlopen for bash and I find it's the worse. But impossibly cool. Did you have a usecase for this or it was just fun?