On Thu Nov 30 15:40:55 2017, zefram@fysh.org wrote:
Show quoted text> Sawyer X via RT wrote:
>
> Your detection of less(1) in the pager list is dubious. You use a
> substring search for the character sequence "less", but that may be
> misleading because it could appear as substring in a $ENV{PAGER} that
> is for a different pager.
I agree. I thought about this and eventually stole it from the detection for adding "-R" to the pager. I figured it would at least be as consistent as it is now, despite being inaccurate.
Show quoted text>
> The use of `$less_bin --version` is dubious, because, per
> ->pagers_guessing, $less_bin may contain shell redirection characters,
> such that "--version" wouldn't necessarily function as a command-line
> argument to less(1). You may need to parse pager strings in more detail.
Good point. I'll improve this by finding the execution file and then calling only that with "--version", which would remove any redirection characters which might have appeared.
Show quoted text>
> The version check on less(1) involves a regexp copied from the groff
> version check, which will never match actual "less --version" output.
Whoops! Fixed and PR was updated.
Show quoted text>
> Where the acceptability of the formatter depends on a sufficiently
> recent less(1), you need to ensure that that is the pager actually
> used, which you are not doing. All you are doing is detecting that a
> sufficiently recent less(1) is somewhere in the list of candidate pagers.
> You probably want to filter the pager list to contain only acceptable
> versions of less(1).
Makes sense. That part was evidently fragile since all I did was check whether one of the possible pagers available is less. I couldn't tell if it would be used. The code then tries each one indepdendently hoping it will work (literallly checking the result of "system()") so it's unassured which are available or will work. Reducing it to "which are available" and then to the first one being "less" makes more sense.
Show quoted text> However, where the first pager setting comes from
> $ENV{PAGER} or $ENV{PERLDOC_PAGER} it would be rude to dishonour that.
> An environmental pager setting, where supplied, should be the only
> candidate pager, such that you will pass up the opportunity to use ToTerm
> rather than use a different pager.
It is possible to simply let those values override my inspection of possible pagers. Instead it currenly only adds it as an optional pager candidate. I think the reason is that a user might have an environment configured for a certain pager by the operating system which doesn't actually exist or is installed.
I am in the opinion that, if you explicitly want something, that's what you should get (even if you didn't personally explicitly stated, but some other configuration did) and that, if that fails, you should be notified.
In other words, if Debian automatically set my EDITOR to vim but I don't have vim installed, I would like to know about instead of whatever used the EDITOR configuration would silently just try something else and open a different editor.
If we both agree on this, I can change the guessing function to explicitly override whatever pager is avaiable by those configurations and then, as a secondary measaure, try to reduce the list to existing pagers, and if the first one is less, continue with the logic.
Does that make sense?
Show quoted text>
> When you are depending on -R, you also need to actually pass -R to the
> pager, which you're not reliably doing. You haven't changed the logic
> for this, which sets $ENV{LESS} if it wasn't set but doesn't do anything
> to pass -R if $ENV{LESS} was set. If you're parsing shell code in pager
> settings, it's probably best to add -R there and leave the environment
> untouched.
I had left it as is since ToTerm sets it in its own formatter. I can move this out of the way, but this would make it a particular ToTerm change that appears outside it. Although, your suggestioon would be safer since it would be parsing the pager string and make sure it's in the right place. Not sure which is best.
Show quoted text> To make ToTerm acceptable, you need to also check that the terminal is of
> a type that accepts the ANSI escape sequences. The existing logic will
> avoid trying ToTerm if $ENV{TERM} has certain values indicating the lack
> of cursor addressability, but that's not sufficient, in two respects.
> Firstly, an addressable cursor does not in the slightest imply the
> use of ANSI escape sequences. And secondly, the check needs to be the
> opposite way round, because the consequences of sending unrecognised
> escape sequences are much worse than the consequences of trying to page
> on a dumb terminal. So you need to check that $ENV{TERM} is set to a
> type that you specifically know accepts these sequences. The default
> behaviour, for a terminal type that is not specifically recognised,
> has to be to conservatively not send the dubious sequences.
So we would have to both make sure that we have less that can understand escape codes as escape codes and to know that the terminal supports them and can display them properly.
For the first we have a solution, for the latter we will need to create a list of known terminals that support escape codes and check ENV{TERM} for them. If we do not know your terminal, we cannot be sure it supports escape codes, and thus move to ToText as a fallback.
If so, this means the logic is:
* If you have an old version of groff
* And your less is old, or
* Your terminal is unknown (meaning it's implicitly known to not support escape codes), then:
-> You get ToText.
* If you have an old version of groff
* And your less is new enough
* And we know your terminal (and implicitly know it to support escape codes), then:
-> You get ToTerm.
* If you have a new enough version of groff, then:
-> You get ToMan
Did I understand it correctly?