This is, perhaps, a silly question, but it’s something that I’ve wondered about: is it possible to, say, define a Ruby/Python/Perl/etc. function in some file and then source it in Bash (to make it available anywhere in the current shell)?
At the moment, I “source” scripts/functions in other languages by creating a bash alias that executes that script… But I wonder if it’s possible for Bash to interpret those other functions directly?
It’s not that hard. You have to take advantage of the language’s features for specifying what code to run. Figuring out how to escape the code and the input is tricky. But its doable: