From 907b402558fdb5650f53ef290c6b941b14983f5b Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sat, 27 Aug 2022 18:05:40 +0200 Subject: [PATCH] homebrew: stat(1) is not protable! Use ls(1) and awk(1) ... --- plugins/homebrew/homebrew.zshrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/homebrew/homebrew.zshrc b/plugins/homebrew/homebrew.zshrc index ff27b11..34f0b69 100644 --- a/plugins/homebrew/homebrew.zshrc +++ b/plugins/homebrew/homebrew.zshrc @@ -33,7 +33,7 @@ function brew() { brew_prefix=$("$real_brew_cmd" --prefix) || return 102 - if [[ $(stat -c %u "$brew_prefix") -eq $UID ]]; then + if [[ $(/bin/ls -ldn "$brew_prefix" | awk '{print $3}') -eq $UID ]]; then # We are the owner of the Homebrew installation. ( [[ $# -eq 0 && -t 1 ]] \ @@ -48,8 +48,8 @@ function brew() { priv_exec="umask 0022 || exit 103; \"$real_brew_cmd\" $*" ( cd /tmp - user="$(stat -c %U "$brew_prefix")" - group="$(stat -c %G "$brew_prefix")" + user="$(/bin/ls -ld "$brew_prefix" | awk '{print $3}')" + group="$(/bin/ls -ld "$brew_prefix" | awk '{print $4}')" [[ $# -eq 0 && -t 1 ]] \ && echo "Running \"$real_brew_cmd\" as user \"$user:$group\" ..." sudo -u "$user" -g "$group" -- sh -c "$priv_exec" -- 2.39.2