scripts/common_functions.sh: add better checks for Darwin