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
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.
<http://kitenet.net/~joey/blog/entry/ten_years_of_free_softwa...;