From 1a855397410ce6d78c67e4d3828ad3f7f78a3b73 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 18 Dec 2022 18:56:47 -0500 Subject: [PATCH] Meta: Find mke2fs on macOS even if HOMEBREW_PREFIX is not set ...as long as `brew` is on the path and `brew --prefix e2fsprogs` tells us where it is. This is for people who don't have `"$(brew shellenv)"` in their .zshrc. --- Meta/.shell_include.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Meta/.shell_include.sh b/Meta/.shell_include.sh index 989f85d443..17697e7250 100755 --- a/Meta/.shell_include.sh +++ b/Meta/.shell_include.sh @@ -20,8 +20,14 @@ die() { find_executable() { paths=("/usr/sbin" "/sbin") - if [ "$(uname -s)" = "Darwin" ] && [ -n "${HOMEBREW_PREFIX}" ]; then - paths+=("${HOMEBREW_PREFIX}/opt/e2fsprogs/bin" "${HOMEBREW_PREFIX}/opt/e2fsprogs/sbin") + if [ "$(uname -s)" = "Darwin" ]; then + if [ -n "${HOMEBREW_PREFIX}" ]; then + paths+=("${HOMEBREW_PREFIX}/opt/e2fsprogs/bin" "${HOMEBREW_PREFIX}/opt/e2fsprogs/sbin") + elif command -v brew > /dev/null 2>&1; then + if prefix=$(brew --prefix e2fsprogs 2>/dev/null); then + paths+=("${prefix}/bin" "${prefix}/sbin") + fi + fi fi executable="${1}"