FYI Your shell script is still not really valid. You should either fix the bash-isms (best option) or target bash specifically in the shebang line.
ShellCheck (http://www.shellcheck.net) should help with making it sh (posix shell) compatible.
Edit: probably more friendly.
/bin/sh though, is a bit of a "special" case - back in the day, it would have been the Bourne Shell (as distinct from Bash, which is the Bourne Again Shell).
These days, it depends on your platform - macOS uses Bash to provide /bin/sh, Debian/etc use Dash, and I believe the BSD's use Almquist (ash).
Dash and Ash (which Dash is a 'descendant' of) are pretty close to POSIX compliant, but 'Bash as /bin/sh', while being 'more strict', doesn't drop support for all Bash-isms, so your script probably works fine on macOS but will fail miserably on a recent Linux or BSD.
Edit: FYI, if anyone wants to properly test portable (i.e. POSIX /bin/sh compatible) shell scripts on macOS, Dash is pretty simple to install from source. I'd still suggest using VM's to test in a variety of shells (Ash, Dash, Posh would give pretty decent coverage) but for quick tests, native Dash will be more representative than Bash.