I started this post back in 2007, when I found a great tutorial on learning bash scripting. This excellent tutorial, written by Daniel Robbins, the Chief Architect of the Gentoo Project, gives two compelling reasons to learn bash:

1. You are already running it. If you are building web tech, chances are that some machine you use is running bash, even if you feel obliged to work on a Windows laptop like me. On Windows, you can run cygwin, which means your scripts will run locally and on your Linux machine. There are some prickly edges, but mostly you can just pretend it’s all one happy unix-ie OS.

2. You are already using it. Chances are you already know some bash if you’ve spent any time where you needed to work in a unix shell. Through geek social learning, it creeps into your consciousness. Many folks start using bash constructs before they are even understood. Like the archaic symbols of some ancient spell woven in the air, the magic works even if you don’t know what it means. However, if you can be inspired to learn what’s really going on, there is great power in bash scripting.

Of course, the real reason for my strong desire to learn bash scripting that I indulge in every month or so, is that I’ve grown tired of repeating myself. It is an old coder’s adage, that by the time you find yourself doing something a third time, you should automate it. Then you never have to do it again. I’d like it to be as quick to for me to write a bash script as to type the commands into a shell. Right now, it still takes several hours for me to write a script, and I sometimes get stumped.

Since I only script intermittently, I thought I’d record in my blog some of the handy tips I have learned from my colleagues and link them with this post over time, so I can refer back to these little bits of wisdom and perhaps other people can also be inspired.

Handy Tutorials:
* Bash by example
* sed
* awk

Bits of Wisdom:
* xargs is your friend

Many thanks to my bash mentors: Eric Bloch, Scott Evans, ptw and Pablo Kang.

For some reason, since I set up my new machine, when I p4 sync I would get directories that aren’t writeable. This means that lzx files won’t compile since the swf needs to be written into the directory.

To work-around this, I tried to just set permissions on all the directories. My first attempt (below), didn’t work…. anyone know why? the second one is more verbose and did work.

$ find * -type d | chmod a+w
chmod: missing operand after `a+w’
Try `chmod –help’ for more information.

Verbose work-around:
$ for i in * ; do if [ -d $i ]; then chmod a+w $i ; fi ; done

A better answer: the chmod command does not accept arguments on stdin, so you can’t just pipe a file list to it:

$ find . -type d -print0 | xargs -0 chmod a+w

xargs is your friend

The OpenLaszlo team has been making great progress supporting SWF9, which is effectively a 3rd runtime after SWF7/8 and DHTML. Check out the weather app running in SWF9. With that app you can’t really see the performance improvements, but they are seeing substantial improvements in startup time with the SWF9 runtime. The SWF9 work is now in trunk — you can download the latest nightly build to check it out. (Report bugs in the open bug base)

They are approaching a 4.1, which will be a “recommended” release for both DHTML and SWF7/8.