mirror of
https://github.com/sharkdp/bat
synced 2026-07-26 17:31:42 +00:00
Fix bat crash with BusyBox less on Windows
- Retrieve less version earlier in src/output.rs. - Skip -K argument if less is detected as BusyBox version. - Reuses the version check for the existing --no-init logic. - Fixes #3518.
This commit is contained in:
+7
-2
@@ -131,8 +131,13 @@ impl OutputType {
|
||||
p.arg("-S"); // Short version of --chop-long-lines for compatibility
|
||||
}
|
||||
|
||||
let less_version = retrieve_less_version(&pager.bin);
|
||||
|
||||
// Ensures that 'less' quits together with 'bat'
|
||||
p.arg("-K"); // Short version of '--quit-on-intr'
|
||||
// The BusyBox version of less does not support -K
|
||||
if less_version != Some(LessVersion::BusyBox) {
|
||||
p.arg("-K"); // Short version of '--quit-on-intr'
|
||||
}
|
||||
|
||||
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
|
||||
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
|
||||
@@ -142,7 +147,7 @@ impl OutputType {
|
||||
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
|
||||
// is not needed anymore.
|
||||
if single_screen_action == SingleScreenAction::Quit {
|
||||
match retrieve_less_version(&pager.bin) {
|
||||
match less_version {
|
||||
None => {
|
||||
p.arg("--no-init");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user