Remove Bashisms & increase portability

Bashisms are removed and portability is increased. Hopefully, the megatest (now) will work on Mac OS X.

These changes were identified using [Heirloom Bourne shell](http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/shells/heirloom-sh/README.html) on NetBSD (after removing Bash). In this shell, the megatest now completes successfully.

If necessary, further viable debugging opportunities might be:

1. Informal, shared access to a Mac OS X box (perhaps at Hack Night); or
1. Mac OS X's underlying [Darwin](https://en.wikipedia.org/wiki/Darwin_%28operating_system%29) OS, either in the form of:

   a. An AWS AMI, such as [Darwin Streaming Server](https://aws.amazon.com/marketplace/pp/ref=csl_clsc_prd?sku=6csyxdbb17tm4wz6a1u30a6xe); or
   a. [PureDarwin](http://stackoverflow.com/questions/tagged/darwin) or [OSx86](https://en.wikipedia.org/wiki/OSx86), perhaps as a guest in [VirtualBox](https://en.wikipedia.org/wiki/VirtualBox). PureDarwin seems pretty immature, though.

The megatest (still) succeeds in Bash on Linux.