Check for bashisms

Software

For better or worse (depending on your disposition), GNU/Linux has become the defacto *nix standard. But there are still plenty of unices out there, even Debian uses ash during start. If you’re concerned with script portability, you should abstain from bashisms.

I normally just call it Linux like a normal person, but this post concerns GNU bash, so I figured I’d make an exception. Purple monkey dishwashers).

A quick way to check your scripts is with the excellent checkbashims script by Yann Dirson and Julian Gilbey. And it’s even available on homebrew, boom.

$ checkbashisms -p retina.sh
==> possible bashism in retina.sh line 29 (<<< here string):
==> _original=`sed "s/this/that/" <<< $_image`
==> possible bashism in retina.sh line 61 (should be 'b = a'):
==> [ `uname` == "Darwin" ] && echo $_html | pbcopy

Heh, whoops. I’ve got some scripts to fix.

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!