4 ms·
OOP in Bash
- deleted 15y ago[deleted]
- skrebbel 15y agoColour me impressed. I thought you needed fancy (relatively) modern stuff like Ruby for decent in-language DSLs, but clearly Bash can do the trick, too. I wonder how decent a programming language you could turn bash into using tricks like these.
- laughinghan 15y agoYou can in fact write a web framework for Bash using tricks like these: Bash on Balls has a HTTP parser and router, a model layer that implements OO similarly to this, even a templating language, esh http://news.ycombinator.com/item?id=2781019 http://news.ycombinator.com/item?id=2781019
- niklasl 15y agoAnd if you're stuck in the Microsoft ecosystem there is DOS on Dope: http://secretgeek.net/dod_intro.asp http://secretgeek.net/dod_intro.asp
- mrspeaker 15y agoHa ha! Brilliant. An incredibly suitable domain name for such and insane monster!
- astral303 15y agoDoesn't look like you can do polymorphism with it, which would be the real utility of this. Objects are globally named, etc. But looks fun!
- iam 15y agoWhy can't you do polymorphism? It looks like he just needs to add vtables to make that work.
- joeyh 15y agoYou don't need bash features to do this either. I wrote shoop (http://shoop.sourceforge.net/ http://shoop.sourceforge.net/) a decade ago. <http://kitenet.net/~joey/blog/entry/ten_years_of_free_software_--_part_10_shoop/> http://kitenet.net/~joey/blog/entry/ten_years_of_free_softwa...;
- btilly 15y agoYou can do this in straight shell, with polymorphism. See http://onestepback.org/articles/poly/sp-shell.html http://onestepback.org/articles/poly/sp-shell.html. And see http://onestepback.org/articles/poly/index.html http://onestepback.org/articles/poly/index.html for the same example in many, many other languages.
- smogzer 15y agodoes anybody know if it works for zsh also ?
- jpr 15y agoThere's insanity, and then there's this...
- supernayan 15y agoHave bash skills? http://blog.audaxhealth.com/jobs http://blog.audaxhealth.com/jobs
- timbowhite 15y agoI used this to make a utility logging class for bash scripts. It prints nicely formatted messages to the console and/or logfile. The format is similar to Linux boot messages. https://github.com/timbowhite/bashtasklog https://github.com/timbowhite/bashtasklog
- kishi 15y agoThis is bad a joke - not only the classes and methods but the individual instances have statically generated names. That means in the examples, for the statically generated "one", "two" and "three" there's no way to assign them to another variable, or pass them as arguments to a function.