[PATCH v4 2/2] tools: Handle PAGER containing arguments
Paul Barker
paul.barker at sancloud.com
Wed Sep 8 13:38:02 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 | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 96882264a2f9..710f1fdcd361 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.33.0
More information about the U-Boot
mailing list