diff --git a/bin/brew b/bin/brew index 4a874ab9a7..92febbbee8 100755 --- a/bin/brew +++ b/bin/brew @@ -1,6 +1,12 @@ #!/bin/bash set +o posix +# Fail fast with concise message when cwd does not exist +if ! [[ -d "$PWD" ]]; then + echo "Error: The current working directory doesn't exist, cannot proceed." >&2 + exit 1 +fi + quiet_cd() { cd "$@" >/dev/null }