
How to do metaprogramming (aka macros) in bash  - jemeshsu
http://simpletondigest.wordpress.com/2012/01/06/building-a-better-macro/
======
viraptor
I was with him until he mentioned that this is included in a real library and
is intended for use... Why would you ever use this in your scripts? Why not
any other sane language with normal quoting rules?

~~~
medlefsen
I would never suggest to anyone that they use bash when there is a better
alternative, but it often happens that you start with a "toy" script and then
it ends up growing and growing. Even in my job (I'm a consultant) I run into
massive bash scripts that do complex jobs.

Not everyone is going to rewrite, and if they're not they should have tools
available to them to help make their scripts more robust. The @macro alias is
just a helpful tool for achieving that without quadrupling the size of your
script.

Thanks for the feedback.

------
kruhft
I tried this before, but the quoting is a nightmare.

~~~
medlefsen
There were a number of nightmarish aspects of it, but with the latest
iteration I haven't had any problems. I can print very complex code from my
macro functions and they will be evaluated without problems. You do have to
use printf '%q ' sometimes though.

~~~
kruhft
Yes, I would think that actually continuing to work on it you would find some
better ways to work around it. Shell is still one of my favorite languages for
textual data munging.

