Skip to content

Commit 3df9d58

Browse files
authored
Merge pull request #3527 from Anchal-T/master
Fix bat crash with BusyBox less on Windows
2 parents c491488 + eb724f2 commit 3df9d58

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Improve native man pages and command help syntax highlighting by stripping overstriking, see #3517 (@akirk)
1010

1111
## Bugfixes
12+
- Fix crash with BusyBox `less` on Windows, see #3527 (@Anchal-T)
1213
- `--help` now correctly honors `--pager=builtin`. See #3516 (@keith-hall)
1314
- `--help` now correctly honors custom themes. See #3524 (@keith-hall)
1415
- Fixed test compatibility with future Cargo build directory changes, see #3550 (@nmacl)

src/output.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ impl OutputType {
131131
p.arg("-S"); // Short version of --chop-long-lines for compatibility
132132
}
133133

134+
let less_version = retrieve_less_version(&pager.bin);
135+
134136
// Ensures that 'less' quits together with 'bat'
135-
p.arg("-K"); // Short version of '--quit-on-intr'
137+
// The BusyBox version of less does not support -K
138+
if less_version != Some(LessVersion::BusyBox) {
139+
p.arg("-K"); // Short version of '--quit-on-intr'
140+
}
136141

137142
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
138143
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
@@ -142,7 +147,7 @@ impl OutputType {
142147
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
143148
// is not needed anymore.
144149
if single_screen_action == SingleScreenAction::Quit {
145-
match retrieve_less_version(&pager.bin) {
150+
match less_version {
146151
None => {
147152
p.arg("--no-init");
148153
}

0 commit comments

Comments
 (0)