From d14accee3981136025ed9c9f946c496ab8351fef Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:34:55 +0800 Subject: [PATCH] brew.sh: fix some stderr redirections to `/dev/null` The order matters here (in a way that I can't explain, unfortunately). Example: bash-3.2$ read -r FOO /dev/null bash: nonexistent: No such file or directory bash-3.2$ read -r FOO 2>/dev/null /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