brew: fail fast when not using bash

This commit is contained in:
XuehaiPan 2021-09-16 21:18:48 +08:00
parent 03017a84b4
commit 1be5e97e82

View File

@ -1,5 +1,14 @@
#!/bin/bash
set +o posix
# Fail fast with concise message when not using bash
# Single brackets is needed here for POSIX compatibility
if [ -z "${BASH_VERSION:-}" ]
then
echo "Error: Bash is required to run brew." >&2
exit 1
fi
set +o posix # as we are using bash now
# Fail fast with concise message when cwd does not exist
if ! [[ -d "${PWD}" ]]
@ -8,13 +17,6 @@ then
exit 1
fi
# Fail fast with concise message when not using bash
if [ -z "${BASH_VERSION:-}" ]
then
echo "Error: Bash is required to run brew." >&2
exit 1
fi
quiet_cd() {
cd "$@" &>/dev/null || return
}