Only read major version when parsing less version
For versions of less that include a point version (eg 581.2), parsing
the whole version 'word' as a usize fails and causes '--no-init' to be
added to less arguments. This prevents less using the alternate screen
and mouse scrolling.
Fixes
@@ -8,7 +8,7 @@ pub fn retrieve_less_version() -> Option<usize> {
fn parse_less_version(output: &[u8]) -> Option<usize> {
if output.starts_with(b"less ") {
let version = std::str::from_utf8(&output[5..]).ok()?;
- let end = version.find(' ')?;
+ let end = version.find(|c: char| !c.is_ascii_digit())?;
version[..end].parse::<usize>().ok()
} else {
None
