Skip to content

Commit 4695cb7

Browse files
davidmhZordrak
authored andcommitted
Don't assume brew is available in the system
All we care about is that GNU grep is available, which could've been installed in a number of ways, not just via Homebrew.
1 parent fe8767d commit 4695cb7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/helpers.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,16 @@ function error_and_proceed() {
147147
export -f error_and_proceed;
148148

149149
function check_dependencies() {
150-
if [[ $(uname) == 'Darwin' ]] && [ $(which brew) ]; then
151-
if ! [ $(which ggrep) ]; then
152-
log 'error' 'A metaphysical dichotomy has caused this unit to overload and shut down. GNU Grep is a requirement and your Mac does not have it. Consider "brew install grep"';
150+
if [[ $(uname) == 'Darwin' ]]; then
151+
# If installed through brew, it will be available as `ggrep`, so we alias it to `grep`
152+
if command -v ggrep >/dev/null 2>&1; then
153+
shopt -s expand_aliases;
154+
alias grep=ggrep;
153155
fi;
154156

155-
shopt -s expand_aliases;
156-
alias grep=ggrep;
157+
if ! grep --version 2>&1 | grep -q "GNU grep"; then
158+
log 'error' 'GNU Grep is a requirement and your Mac does not have it. Consider installing it with `brew install grep` or `nix profile install nixpkgs#gnugrep`';
159+
fi;
157160
fi;
158161
};
159162
export -f check_dependencies;

0 commit comments

Comments
 (0)