Most of these are simple changes. I added an `is_pager_less` and a `get_pager`
function to `pager.sh`. In order for this function to be available for use
inside `pager.sh`, I had to define the functions before setting defaults.
The `is_pager_less` function is then used for the `--search-pattern` to see if
the `$SCRIPT_PAGER` supports the `--search-pattern` flag. Right now, the only
supported pager is `less`.
Previously, if you tried to use the `-F`/`--fixed strings` option for ripgrep in
combination with the `--less-search-pattern` option, `less` would either a)
match a different pattern than intended, since it would be interpreted as a
regular expression, or b) refuse to start if it detected an invalid pattern.
This change keeps track of whether or not the `--fixed-strings` option was
passed in. If both it and the `--less-search-pattern` was passed in, a `^R`
(Control-R) control character is prepended to the search pattern. This instructs
less to *not* treat the pattern as a regular expression.
The `less` pager can search for a pattern. In addition, you can instruct it to
search for a given pattern on startup by passing in the `-p` flag followed by
the pattern to search for. Since the `batgrep` command is searching for a
pattern and invoking the pager, it has the opportunity to take advantage of this
functionality.
This patch adds a `-p` flag to `batgrep` which, in turn, passes `-p $PATTERN` to
the pager invoked. This may be specific to `less`, which is
unfortunate. However, it doesn't seem like there would be a convenient way to
make this more general. In addition, most pagers forward the actual paging to
`less` anyways.
To clarify that the behavior is specific to `less`, the long name is
`--less-search-pattern`.