From: Paul Barker Date: Wed, 8 Sep 2021 11:38:02 +0000 (+0100) Subject: tools: Handle PAGER containing arguments X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=0d60e5d8e9a7abc46751664a0857c66280d43d2c;p=u-boot.git 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 --- 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)