Bashisms
A while back I spent quite a bit of time writing Korn Shell scripts, but it was a while back. The last few years it’s been all Bash for me, in fact these days I try to write everything in Python.
Anyway that means that just now trying to write a POSIX Shell script has proved a little challenging.
The manual is rather long and wordy, although it seems like it’s all there. There’s the Shell Command Language, although things you think of as being part of the shell don’t seem to be – ie. “test”, which implements the “[” in “if [ x = y ]”, that’s separate.
Despite a bit of googling I couldn’t find a good list of bashisms and their POSIX replacements, there’s a few mentioned here. I did find the next better thing, a script that checks for you, “checkbashisms”, it’s in the Debian devscripts package.
And if you’re running Ubuntu you can switch to using /bin/dash for your script temporarily, if it runs under dash it’s probably pretty safe. Let’s be honest most people use bash anyway 🙂
If anyone does have a good list of bashisms I’d love to see it.
Posted by mike on Tuesday April 22nd, 2008, tagged with linux, plau, pltc | 3 comments