]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: Handle PAGER containing arguments
authorPaul Barker <paul.barker@sancloud.com>
Wed, 8 Sep 2021 11:38:02 +0000 (12:38 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 24 Sep 2021 18:30:46 +0000 (14:30 -0400)
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 <paul.barker@sancloud.com>
tools/patman/tools.py

index 96882264a2f913889636f0cce41c39617bf19907..710f1fdcd361e4820a56c62ef37a3dbf77b3e88e 100644 (file)
@@ -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)