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.
This commit is contained in:
Nico Weber 2022-12-18 18:56:47 -05:00 committed by Andrew Kaster
parent 15ce757f12
commit 1a85539741
Notes: sideshowbarker 2024-07-17 06:40:35 +09:00

View File

@ -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}"