Portability fixes for popen.test (for when /bin/sh is not bash)