Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ctypes.sh: A foreign function interface for bash (github.com/taviso)
86 points by gkfasdfasdf on Oct 10, 2020 | hide | past | favorite | 8 comments


I really enjoy when people enjoy poking a bit of fun at themselves:

———

Here is what people have been saying about ctypes.sh:

"that's disgusting" "this has got to stop" "you've gone too far with this" "is this a joke?" "I never knew the c could stand for Cthulhu." You can read more about ctypes.sh and see it in action on the Wiki


This is absolutely brilliant. I tried doing something similar in 1997 but didn't know enough and got frustrated.

Basically, with this, you can call --any-- dynamic library function from bash. Pretty impressive.


Windows did it first (rundll32.exe)


You know, interestingly, in the 12 years I've used Linux, I've never once needed something like rundll32, but I've needed it in Windows several times. I suppose because Microsoft buries the advanced stuff as function calls in dlls, and Linux just lets you do whatever.


Linux just lets you do whatever.

Not sure what you mean by this. That Linux offers command line tools that generate textual output vs. putting the functionality in libraries?

My understanding is that Microsoft recognized in the 1990s that shell scripting blows. (See for example “Bash Error Handling”[0] - a web comic with 273 points and 97 comments - which was on the front page in the past day.)

MS expected that people would use proper programming languages to do complex tasks that are frequently (and arguably unfortunately) performed via shell scripts on *nix and batch files on Windows. This is why Windows Scripting Host[1] exists. Functionality in DLLs is easily accessible without resorting to hacks like rundll32.exe.

(I don’t know the 0 - https://news.ycombinator.com/item?id=24727495

1 - https://en.m.wikipedia.org/wiki/Windows_Script_Host


Whoops.

  s/\(I don’t know the //


But I suppose the name was inspired by Python's module:

https://docs.python.org/3/library/ctypes.html

(which I think should have been mentioned in the README)


This is cool. Gives some intuition as to how object files work.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: