From 00e21bfdf7e732f270cc043ed1f38cf1248c46d2 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 26 May 2018 05:30:35 -0400 Subject: [PATCH] brew: Conciser error when run from nonexistent directory --- bin/brew | 6 ++++++ 1 file changed, 6 insertions(+) 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 }