Skip to content

Commit

Permalink
brew.sh: fix some stderr redirections to /dev/null
Browse files Browse the repository at this point in the history
The order matters here (in a way that I can't explain, unfortunately).

Example:

    bash-3.2$ read -r FOO <nonexistent 2>/dev/null
    bash: nonexistent: No such file or directory

    bash-3.2$ read -r FOO 2>/dev/null <nonexistent
    # no output

Fixes Homebrew/discussions#5653.
  • Loading branch information
carlocab committed Oct 4, 2024
1 parent 4671af4 commit d14acce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,13 @@ GIT_REVISION=$("${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" rev-parse HEAD 2>/d
# safe fallback in case git rev-parse fails e.g. if this is not considered a safe git directory
if [[ -z "${GIT_REVISION}" ]]
then
read -r GIT_HEAD <"${HOMEBREW_REPOSITORY}/.git/HEAD" 2>/dev/null
read -r GIT_HEAD 2>/dev/null <"${HOMEBREW_REPOSITORY}/.git/HEAD"
if [[ "${GIT_HEAD}" == "ref: refs/heads/master" ]]
then
read -r GIT_REVISION <"${HOMEBREW_REPOSITORY}/.git/refs/heads/master" 2>/dev/null
read -r GIT_REVISION 2>/dev/null <"${HOMEBREW_REPOSITORY}/.git/refs/heads/master"
elif [[ "${GIT_HEAD}" == "ref: refs/heads/stable" ]]
then
read -r GIT_REVISION <"${HOMEBREW_REPOSITORY}/.git/refs/heads/stable" 2>/dev/null
read -r GIT_REVISION 2>/dev/null <"${HOMEBREW_REPOSITORY}/.git/refs/heads/stable"
fi
unset GIT_HEAD
fi
Expand Down

0 comments on commit d14acce

Please sign in to comment.