From: Alexander Barton Date: Wed, 24 May 2023 10:11:18 +0000 (+0200) Subject: homebrew: Enhance code, no functional changes X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a29b553bdd4e27fb863ea835fac6d56994a4cab7;p=ax-zsh.git homebrew: Enhance code, no functional changes --- diff --git a/plugins/homebrew/homebrew.zshrc b/plugins/homebrew/homebrew.zshrc index 8759da5..12a0f22 100644 --- a/plugins/homebrew/homebrew.zshrc +++ b/plugins/homebrew/homebrew.zshrc @@ -18,14 +18,14 @@ function brew() { # installed by Homebrew. # - Call the "real" brew(1) command. - if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then + if [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then real_brew_cmd="/home/linuxbrew/.linuxbrew/bin/brew" - elif [ -x /opt/homebrew/bin/brew ]; then + elif [[ -x /opt/homebrew/bin/brew ]]; then real_brew_cmd="/opt/homebrew/bin/brew" - elif [ -x /usr/local/bin/brew ]; then + elif [[ -x /usr/local/bin/brew ]]; then real_brew_cmd="/usr/local/bin/brew" else - if [ "$1" != "shellenv" ] && [ "$1" != "--prefix" ]; then + if [[ "$1" != "shellenv" && "$1" != "--prefix" ]]; then echo "Oops, real \"brew\" command not found!? [for \"$1\"]" >&2 fi return 101 @@ -38,13 +38,12 @@ function brew() { if [[ $(/bin/ls -ldn "$HOMEBREW_REPOSITORY" | awk '{print $3}') -eq $UID ]]; then # We are the owner of the Homebrew installation. ( - [[ $# -eq 0 && -t 1 ]] \ - && echo "Running \"$real_brew_cmd\" ..." + [[ $# -eq 0 && -t 1 ]] && echo "Running \"$real_brew_cmd\" ..." umask 0022 || return 103 "$real_brew_cmd" "$@" ) else - # We are a different user than the owner of the Homebew + # We are a different user than the owner of the Homebrew # installation. So we need to change the user when running the # real "brew" command! priv_exec="umask 0022 || exit 103; \"$real_brew_cmd\" $*"