File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -273,7 +273,7 @@ TEST(pager_test, find_pager_program) {
273273 auto pager = find_pager_program (os);
274274 ASSERT_TRUE (pager);
275275 EXPECT_EQ (" /whatever/bin/less" , pager->name );
276- EXPECT_TRUE (pager->args . empty ( ));
276+ EXPECT_THAT (pager->args , :: testing::ElementsAre ( " -R " ));
277277 }
278278
279279 os.setenv (" PAGER" , " cat" );
Original file line number Diff line number Diff line change 4242#endif
4343
4444#include < dwarfs/os_access.h>
45+ #include < dwarfs/string.h>
4546#include < dwarfs/tool/pager.h>
4647
4748namespace dwarfs ::tool {
@@ -77,14 +78,20 @@ std::optional<pager_program> find_pager_program(os_access const& os) {
7778 sv.remove_suffix (1 );
7879 }
7980
80- std::filesystem::path p{std::string (sv)};
81+ // split into program and arguments
82+ auto args = split_to<std::vector<std::string>>(sv, ' ' );
83+ std::filesystem::path p{args.front ()};
84+ args.erase (args.begin ());
8185
8286 if (os.access (p, X_OK ) == 0 ) {
83- return pager_program{p, {} };
87+ return pager_program{p, args };
8488 }
8589
8690 if (auto exe = os.find_executable (p); !exe.empty ()) {
87- return pager_program{exe, {}};
91+ if (exe.filename () == " less" && args.empty ()) {
92+ args.push_back (" -R" );
93+ }
94+ return pager_program{exe, args};
8895 }
8996 }
9097
You can’t perform that action at this time.
0 commit comments