Bug 10816 - less: -R is rejected as CLI argument (but works at the env var LESS)
Summary: less: -R is rejected as CLI argument (but works at the env var LESS)
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-27 09:38 UTC by avih
Modified: 2018-02-27 10:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description avih 2018-02-27 09:38:52 UTC
Using busybox git current master (2328690) on Ubuntu 16.04, with CONFIG_FEATURE_LESS_RAW enabled, running:
  ./busybox less -R path/to/file
Rejects the -R arg and prints the help.

Setting the env var LESS=-R does work as expected and filters out raw escapes.

It appears that getopt setup is missing "R" .

This patch fixes the issue for me:

diff --git a/miscutils/less.c b/miscutils/less.c
index 97ab1e6..bfdf507 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1814,7 +1814,7 @@ int less_main(int argc, char **argv)
         * -s: condense many empty lines to one
         *     (used by some setups for manpage display)
         */
-       getopt32(argv, "EMmN~I" IF_FEATURE_LESS_TRUNCATE("S") /*ignored:*/"s");
+       getopt32(argv, "EMmN~I" IF_FEATURE_LESS_TRUNCATE("S") /*ignored:*/"s" IF_FEATURE_LESS_RAW("R"));
        argv += optind;
        num_files = argc - optind;
        files = argv;
Comment 1 avih 2018-02-27 10:17:35 UTC
Sorry, "R" should be right after "S". I didn't realize the order matters and it did accept -R with the posted patch, just didn't do anything about it.

With the R just after S (and before s) - it actually works as expected.

I also noticed that flag_change(void) at less.c also doesn't have a reference to 'R', but I don't know what it's used for (it's inside #if ENABLE_FEATURE_LESS_DASHCMD) and whether it should be there or not.
Comment 2 Denys Vlasenko 2018-02-27 10:48:29 UTC
Fixed in git, thanks.
Comment 3 avih 2018-02-27 10:54:02 UTC
Thanks for the quick fix. Confirmed working now.