1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-26 09:56:13 +01:00

Fix less pager by adding '-R' to LESS env

This commit is contained in:
Daniel Mach 2023-08-01 13:51:33 +02:00
parent 001bbdf365
commit 56747274d3

View File

@ -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()