02/14/2006

One thing I honestly enjoy about being a programmer is the complete confusion that can be sown with a piece of particularly clever code. Shell scripting can be especially confusing to read. Today a post on a Linux mailing list to which I subscribe had a beautiful example:

So it seems obvious that one could do something like this:

for i in `find . -name “*.m4a”`; do ffmpeg -i “$i” -acodec mp3 -ac 2 -ab 192 “${i%m4a}mp3”; done && find . -name “*.m4a” -exec rm -f {} ;

That’s a direct cut-and-paste from the message. The best part is the “it seems obvious that…” line. To a shell programmer, the command is in fact obvious. To a mere mortal, it’s unbelievably obfuscated.

Talk about job security… I wave my magic wand and do things like this, and they just work. Heaven help the client who asks to see the man behind the curtain.