1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 09:16:14 +01:00

Merge pull request #1376 from dmach/fix-less

Fix less pager by adding '-R' to LESS env
This commit is contained in:
Daniel Mach 2023-08-07 10:23:20 +02:00 committed by GitHub
commit b8f10a1acd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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