[PATCH v2 2/2] tools: Handle PAGER containing arguments

Paul Barker paul.barker at sancloud.com
Fri Aug 13 18:25:00 CEST 2021


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 at sancloud.com>
---
 tools/patman/tools.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 96882264a2..92e3240470 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,9 @@ 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')
+        pager = [shutil.which('less')]
     if not pager:
-        pager = 'more'
-    command.Run(pager, fname)
+        pager = ['more']
+    command.Run(*pager, fname)
-- 
2.31.1



More information about the U-Boot mailing list