eth-p / eth-p/bat-extras

Scripts don't tokenize PAGER environment variable properly.

Open
#25 0 comments 0 reactions 1 assignee Claimed by @eth-p View on GitHub
batdiff batgrep batwatch bug
Dominant language
Shell
Stars
1.6k
Forks
95
PR merge metrics
No merged PRs in 30d

Description

Original issue:
>**lilyball [6 hours ago](https://github.com/eth-p/bat-extras/commit/9f983891fd4e7da9933616a0e73ea8271a67b535#r38887406
)**
>This won't actually tokenize like the shell does (and like bat does), it merely splits on IFS. That's certainly better than before as it will handle less -R, but it won't handle e.g. foo "one two".
>
>Using read -d '' -a SCRIPT_PAGER_CMD <<<"$PAGER" would at least handle backslash escapes (including escaped spaces), but still wouldn't handle quotes.
>
>I'm not sure if bash actually has any way of truly parsing it with quotes outside of using something like eval "SCRIPT_PAGER_CMD=($PAGER)", but that's trivial to break out of with a stray ), and it also does a bunch of substitution that bat`'s tokenization doesn't do (e.g. variable substitution, tilde substitution, etc).
>
> Ultimately, splitting on IFS is better than nothing. Though the read approach would at least allow for some escaping (with backslashes).

This might be able to be done with `awk` and a `read` loop.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.