Testing Scripts for POSIX Compliance
It’s always important to test your shell scripts before putting them into production. This becomes even more important when you create scripts that need to run on a wide variety of operating systems and shells. In this section, we’ll look at a few ways to perform that testing.
Creating Scripts on a POSIX-compliant Shell
When you first start creating your scripts, you might want to use an interpreter shell that’s completely POSIX-compliant. Be aware though, that some POSIX-compliant shells still allow you to use certain bashisms. That’s because POSIX defines a minimum standard that an operating system or shell must meet, and doesn’t prohibit adding extensions. For example, sh
on FreeBSD allows these two bashisms:
- Using
echo -e
for output. - Using
==
for text string comparisons.
Now, I haven’t extensively tested sh
on FreeBSD to see exactly how many bashisms it allows. But...