Skip to content

Commit 8b13235

Browse files
committed
Fix brew-specific check
When we find a brew-installed grep, we create an alias from ggrep to grep, but an alias can't be defined and used in the same parsing unit, so we exit early instead. See: https://www.shellcheck.net/wiki/SC2262
1 parent 4695cb7 commit 8b13235

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/helpers.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ function check_dependencies() {
152152
if command -v ggrep >/dev/null 2>&1; then
153153
shopt -s expand_aliases;
154154
alias grep=ggrep;
155+
156+
# The alias can't be defined and used in the same parsing unit. But
157+
# since we know the correct package is installed, we can exit early.
158+
exit
155159
fi;
156160

157161
if ! grep --version 2>&1 | grep -q "GNU grep"; then

test/install_deps.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ set -uo pipefail;
33

44
if [[ $(uname) == 'Darwin' ]] && [ $(which brew) ]; then
55
brew install grep;
6+
if [[ -n ${GITHUB_PATH+x} ]]; then
7+
echo "/opt/homebrew/opt/grep/libexec/gnubin" >> $GITHUB_PATH
8+
fi
69
fi;

0 commit comments

Comments
 (0)