When busybox is configured to ENABLE_LESS, running `busybox man docs/busybox.1` creates output with lots of escaped ANSI escape sequences like `\e[1m`. The commonly-used full version of less, less 458 from www.greenwoodsoftware.com/less, has an option -R which asks less to output raw ANSI color chars: > -R or --RAW-CONTROL-CHARS > Like -r, but only ANSI "color" escape sequences are output in > "raw" form. Unlike -r, the screen appearance is maintained cor- > rectly in most cases. ANSI "color" escape sequences are > sequences of the form: > > ESC [ ... m > > where the "..." is zero or more color specification characters > For the purpose of keeping track of screen appearance, ANSI > color escape sequences are assumed to not move the cursor... But busybox less doesn't support such thing at all. Extra info: Working mans: PAGER='less -R' busybox man docs/busybox.1 PAGER='more' busybox man docs/busybox.1 PAGER='busybox more' busybox man docs/busybox.1 Failing mans: PAGER='less' busybox man docs/busybox.1 PAGER='busybox less' busybox man docs/busybox.1
Additions: Working: PAGER=less man docs/busybox.1 Failing PAGER='busybox less' man docs/busybox.1 It seems that man-db has some special handling for less.
*** Bug 5546 has been marked as a duplicate of this bug. ***
Created attachment 7436 [details] [PATCH 1/2] less: add support for -R option
Created attachment 7441 [details] [PATCH 2/2] less: accept the command line options from the environment variable
A cover letter that I sent to the list before it rejected my message: Hi, chained are two patches that add make the less applet behave well with tools that use coloring and paging at the same time. My first busybox patches, so I beg for some understanding if I didn't get things right. Issues have been reported for nmcli, systemd and git upstreams (perhaps more) all of the falling victim to a rather reasonable assumption that a thing called "less" behaves like "less" (in support of "-R" option in particular). I guess the implausibility of teaching all of the affected tools to do some sort of capability assessment of pager's capabilities justifies the slight growth in the applet size. An alternative way would be to use the "more" applet instead somehow. All of the afforementioned tools prefer "less" over "more" for obvious reasons, but perhaps the busybox applet could just dispatch to "more" if it sees a "LESS" environment variable with options it doesn't understand. "more" works well with ANSI control sequences, at the cost of not being able to scroll backwards. Thank you, Lubo
Added support to -R and $LESS in git