In my case I mistakenly had this at the top:
#!/usr/bin/sh
after changing to
#!/bin/bash
I'm good now. It is after all, a bash script as they say.