E pur si muove

Cross platform shell scripts

Thursday, September 24, 2009

At work we have an rather elaborate collection of shell scripts that builds our softweare and all it's dependencies on about 7 UNIX variants as well as on Windows. Shell seemed like a good choice when we started to write those scripts: it is available on all hosts (using Cygwin on Windows) and with some care you can do most task in a portable way, ssh and scp are at your fingertips to do things on remote hosts without any extra hassle etc.

The thing I didn't realise is just how extrordinary expensive forking is on Windows. And when having lots of shell that's what you're doing all the time (cut, tr, grep, awk, ...), on UNIX you generally don't even notice it but on Windows it just grinds to a halt.

This basically means I'm slowly moving to replacing the scripts in Python. Each time I need to modify something I consider the cost of re-writing it in Python and of keeping it in shell. Some critical parts are already replaced by Python code and the speedup is impressive.

So next time you need cross-platform scripts, think about how much work it will need to do on Windows. Forking is expensive. Sadly.

Thursday, September 24, 2009 |


New comments are not allowed.

Subscribe to: Post Comments (Atom)