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.
if [[ -n "$RIPGREP_CONFIG_PATH" && -e "$RIPGREP_CONFIG_PATH" ]]; then
# shellcheck disable=SC2013
for arg in $(cat "$RIPGREP_CONFIG_PATH"); do
case "$arg" in
--context=*)
val="${arg:10}"
OPT_CONTEXT_BEFORE="$val"
OPT_CONTEXT_AFTER="$val"
;;
--before-context=*)
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"
# shellcheck disable=SC2046
setargs $(cat "$RIPGREP_CONFIG_PATH")
while shiftopt; do
case "$OPT" in
-A | --after-context) shiftval; OPT_CONTEXT_AFTER="$OPT_VAL" ;;
-B | --before-context) shiftval; OPT_CONTEXT_BEFORE="$OPT_VAL" ;;
-C | --context)
shiftval
OPT_CONTEXT_BEFORE="$OPT_VAL"
OPT_CONTEXT_AFTER="$OPT_VAL"
;;
esac
done
fi
# Parse arguments.
resetargs
while shiftopt; do
case "$OPT" in