From 0d60e5d8e9a7abc46751664a0857c66280d43d2c Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Wed, 8 Sep 2021 12:38:02 +0100 Subject: [PATCH] tools: Handle PAGER containing arguments When printing full help output from a tool, we should be able to handle a PAGER variable which includes arguments, e.g. PAGER='less -F'. Signed-off-by: Paul Barker --- tools/patman/tools.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/patman/tools.py b/tools/patman/tools.py index 96882264a2..710f1fdcd3 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -5,6 +5,7 @@ import glob import os +import shlex import shutil import struct import sys @@ -588,9 +589,10 @@ def PrintFullHelp(fname): Args: fname: Path to a file containing the full help message """ - pager = os.getenv('PAGER') + pager = shlex.split(os.getenv('PAGER', '')) if not pager: - pager = shutil.which('less') + lesspath = shutil.which('less') + pager = [lesspath] if lesspath else None if not pager: - pager = 'more' - command.Run(pager, fname) + pager = ['more'] + command.Run(*pager, fname) -- 2.39.5