batgrep: Clean up handling of RIPGREP_CONFIG_PATH

This commit is contained in:
Ethan P 2020-10-29 01:28:26 -07:00
parent 65a2f7561e
commit 7549ffd986
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -47,45 +47,23 @@ fi
# Parse RIPGREP_CONFIG_PATH. # Parse RIPGREP_CONFIG_PATH.
if [[ -n "$RIPGREP_CONFIG_PATH" && -e "$RIPGREP_CONFIG_PATH" ]]; then if [[ -n "$RIPGREP_CONFIG_PATH" && -e "$RIPGREP_CONFIG_PATH" ]]; then
# shellcheck disable=SC2013 # shellcheck disable=SC2046
for arg in $(cat "$RIPGREP_CONFIG_PATH"); do setargs $(cat "$RIPGREP_CONFIG_PATH")
case "$arg" in while shiftopt; do
--context=*) case "$OPT" in
val="${arg:10}" -A | --after-context) shiftval; OPT_CONTEXT_AFTER="$OPT_VAL" ;;
OPT_CONTEXT_BEFORE="$val" -B | --before-context) shiftval; OPT_CONTEXT_BEFORE="$OPT_VAL" ;;
OPT_CONTEXT_AFTER="$val" -C | --context)
;; shiftval
OPT_CONTEXT_BEFORE="$OPT_VAL"
--before-context=*) OPT_CONTEXT_AFTER="$OPT_VAL"
val="${arg:17}"
OPT_CONTEXT_BEFORE="$val"
;;
--after-context=*)
val="${arg:16}"
OPT_CONTEXT_AFTER="$val"
;;
-C*)
val="${arg:2}"
OPT_CONTEXT_BEFORE="$val"
OPT_CONTEXT_AFTER="$val"
;;
-B*)
val="${arg:2}"
OPT_CONTEXT_BEFORE="$val"
;;
-A*)
val="${arg:2}"
OPT_CONTEXT_AFTER="$val"
;; ;;
esac esac
done done
fi fi
# Parse arguments. # Parse arguments.
resetargs
while shiftopt; do while shiftopt; do
case "$OPT" in case "$OPT" in