Add message for --search-pattern and no pager

I should probably find a more elegant way to split
an error message across multiple lines in the future.
This commit is contained in:
Ethan P 2020-01-17 20:39:32 -08:00
parent 63a9929592
commit 3e9969de76
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -139,6 +139,7 @@ if [[ "$OPT_CONTEXT_BEFORE" -eq 0 && "$OPT_CONTEXT_AFTER" -eq 0 ]]; then
OPT_HIGHLIGHT=false OPT_HIGHLIGHT=false
fi fi
# Handle the --search-pattern option.
if [[ "$OPT_SEARCH_PATTERN" ]]; then if [[ "$OPT_SEARCH_PATTERN" ]]; then
if is_pager_less; then if is_pager_less; then
if [[ "$OPT_FIXED_STRINGS" ]]; then if [[ "$OPT_FIXED_STRINGS" ]]; then
@ -150,9 +151,16 @@ if [[ "$OPT_SEARCH_PATTERN" ]]; then
else else
SCRIPT_PAGER_ARGS+=(-p "$PATTERN") SCRIPT_PAGER_ARGS+=(-p "$PATTERN")
fi fi
elif [[ -z "$(pager_name)" ]]; then
print_error "$(
echo "The -p/--search-pattern option requires a pager, but" \
"the pager was explicitly disabled by \$BAT_PAGER or the" \
"--paging option."
)"
exit 1
else else
print_error "Unsupported pager '$(pager_name)' for option "\ print_error "Unsupported pager '%s' for option -p/--search-pattern" \
"-p/--search-pattern" "$(pager_name)"
exit 1 exit 1
fi fi
fi fi