Implicit Bash Script
This Bash script checks the type of the underlying operating systems and then does some stuff specific to it. The implicit assumption of this script is, that it will run on two operating systems only:
- Ubuntu 12.04 codenamed Precise Pangolin and
- Debian 6.0 codenamed Squeeze.
If it’s run on a different version, it will implicitly and wrongly assume that it’s running on Debian 6.0 codenamed Squeeze and will probably break things in ways that you haven’t ever imagined.
Furthermore it assumes that
/bin/sh is Bash and it’ll probably throw an error on
systems that link
/bin/sh to a different shell like the Z shell (zsh), that is if the
script uses syntax or features specific to Bash.
Explicit Bash Script
This more explicit version of the same script explicitly checks for the two supported operating systems an outputs a message otherwise. A system administrator using this script on an unsupported system for the first time will find out easily where to look for an error.
Furthermore it explicitly uses
/bin/bash making sure that it’ll work well on systems
using a different shell as
Carefully avoid implicit assumptions in your code as they will make it fail in obscure ways as soon as conditions change.