Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
OOP in Bash (madscience.nl)
108 points by fogus on July 19, 2011 | hide | past | favorite | 13 comments


You don't need bash features to do this either. I wrote shoop (http://shoop.sourceforge.net/) a decade ago.

<http://kitenet.net/~joey/blog/entry/ten_years_of_free_softwa...;


Colour 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.


You 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


And if you're stuck in the Microsoft ecosystem there is DOS on Dope: http://secretgeek.net/dod_intro.asp


You can do this in straight shell, with polymorphism. See http://onestepback.org/articles/poly/sp-shell.html.

And see http://onestepback.org/articles/poly/index.html for the same example in many, many other languages.


Doesn'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!


Why can't you do polymorphism? It looks like he just needs to add vtables to make that work.


Ha ha! Brilliant. An incredibly suitable domain name for such and insane monster!


This 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.


I 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



does anybody know if it works for zsh also ?


There's insanity, and then there's this...




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

Search: