Greg's Wiki has a post on adapting bash scripts for Dash that points out a lot of 'bashisms' - extra features that are non-standard but are a part of bash. Avoiding those bashisms can help to make your script friendlier to different environments. This particularly answers some of your questions. For instance, yes, there are operators that differ (like ==
), but there are a standard Posix set that should work in all environments.
For more thorough reading, you can check out the Posix standard, which all shells should comply to. Particularly, the volume on "Shell & Utilities".
What I find more challenging than the shell differences are the command differences. Many Linux systems have GNU find
, but if you're writing a portable script, don't rely on your own man find
, because there are lots of systems out there with BSD find
, which has a different feature set. If you're writing scripts for busybox, you'll find there are different versions with entirely different nc
s. Those are the kinds of things that always get me when I deploy a script to different environments.
For extra reading on good shell scripting practices, there is also a good resource on David Pashley's blog: Writing Robust Bash Shell Scripts
Also, make sure you read Gilles answers and comments on this site. He has lots of tips about making sure you use portable code.