Bugfix: Replace bashisms with standard sh to fix build on non-BASH systems

Note: I have not actually tested this on a non-BASH system yet.

Downstream Gentoo bug: https://bugs.gentoo.org/show_bug.cgi?id=524332