diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 4298daab67..aafae72407 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -311,7 +311,7 @@ EOS # only allow one instance of brew update lock update - chdir "$HOMEBREW_REPOSITORY" + safe_cd "$HOMEBREW_REPOSITORY" git_init_if_necessary # rename Taps directories # this procedure will be removed in the future if it seems unnecessary @@ -382,7 +382,7 @@ EOS pull "$DIR" done - chdir "$HOMEBREW_REPOSITORY" + safe_cd "$HOMEBREW_REPOSITORY" if [[ -n "$HOMEBREW_UPDATED" || -n "$HOMEBREW_UPDATE_FAILED" || diff --git a/Library/brew.sh b/Library/brew.sh index 8d55601c0f..b3315a301b 100644 --- a/Library/brew.sh +++ b/Library/brew.sh @@ -20,7 +20,7 @@ odie() { exit 1 } -chdir() { +safe_cd() { cd "$@" >/dev/null || odie "Error: failed to cd to $*!" }