From a6a1e5552241dc57fc9ec85261a3d9efb44244dd Mon Sep 17 00:00:00 2001 From: Ethan P Date: Wed, 28 Oct 2020 19:15:48 -0700 Subject: [PATCH] batgrep: Remove hardcoded reference to ripgrep executable --- lib/constants.sh | 5 ++++- src/batgrep.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/constants.sh b/lib/constants.sh index dc2a317..ba6e519 100644 --- a/lib/constants.sh +++ b/lib/constants.sh @@ -8,10 +8,13 @@ if [[ -z "$__LIB_CONSTANTS_INITIALIZED" ]]; then __LIB_CONSTANTS_INITIALIZED=true -# Constants +# Constants: Executables EXECUTABLE_BAT="$(command -v bat 2>/dev/null || command -v batcat 2>/dev/null || echo "bat")" EXECUTABLE_GIT="git" EXECUTABLE_DELTA="delta" +EXECUTABLE_RIPGREP="rg" + +# Constants: Program PROGRAM="$(basename "$0" .sh)" PROGRAM_HOMEPAGE="https://github.com/eth-p/bat-extras" PROGRAM_COPYRIGHT="Copyright (C) 2019-2020 eth-p | MIT License" diff --git a/src/batgrep.sh b/src/batgrep.sh index 6165809..2d4c9a3 100755 --- a/src/batgrep.sh +++ b/src/batgrep.sh @@ -257,10 +257,10 @@ main() { ) if "$READ_FROM_STDIN"; then - rg "${COMMON_RG_ARGS[@]}" <<< "$STDIN_DATA" + "$EXECUTABLE_RIPGREP" "${COMMON_RG_ARGS[@]}" <<< "$STDIN_DATA" return $? else - rg "${COMMON_RG_ARGS[@]}" + "$EXECUTABLE_RIPGREP" "${COMMON_RG_ARGS[@]}" return $? fi }