diff mbox series

[v4,2/2] tools: Handle PAGER containing arguments

Message ID 20210908113802.5252-3-paul.barker@sancloud.com
State Accepted
Commit 0d60e5d8e9a7abc46751664a0857c66280d43d2c
Delegated to: Tom Rini
Headers show
Series Refactor and improve full help output from tools | expand

Commit Message

Paul Barker Sept. 8, 2021, 11:38 a.m. UTC
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 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Tom Rini Sept. 25, 2021, 12:37 a.m. UTC | #1
On Wed, Sep 08, 2021 at 12:38:02PM +0100, Paul Barker wrote:

> 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>

Applied to u-boot/next, thanks!
diff mbox series

Patch

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)