Remove bashisms as shebang says /bin/sh and on Debian this is dash

 * Replace == with = and ensure operands are always quoted as = is a string comparison
 * Leave in $(...) evaluation on the basis of this page http://mywiki.wooledge.org/BashFAQ/082