From 56747274d3a7240154ea427cf40a8ac0756063c4 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 1 Aug 2023 13:51:33 +0200 Subject: [PATCH] Fix less pager by adding '-R' to LESS env --- osc/core.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osc/core.py b/osc/core.py index c5c81d55..5d8df9c6 100644 --- a/osc/core.py +++ b/osc/core.py @@ -4401,11 +4401,21 @@ def run_pager(message, tmp_suffix=''): else: tmpfile.write(message) tmpfile.flush() + + env = os.environ.copy() + pager = os.getenv("PAGER", default="").strip() pager = pager or get_default_pager() + + # LESS env is not always set and we need -R to display escape sequences properly + less_opts = os.getenv("LESS", default="") + if "-R" not in less_opts: + less_opts += " -R" + env["LESS"] = less_opts + cmd = shlex.split(pager) + [tmpfile.name] try: - run_external(*cmd) + run_external(*cmd, env=env) finally: tmpfile.close()