U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Barker <paul.barker@sancloud.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
	u-boot@lists.denx.de
Cc: Paul Barker <paul.barker@sancloud.com>
Subject: [PATCH v4 2/2] tools: Handle PAGER containing arguments
Date: Wed,  8 Sep 2021 12:38:02 +0100	[thread overview]
Message-ID: <20210908113802.5252-3-paul.barker@sancloud.com> (raw)
In-Reply-To: <20210908113802.5252-1-paul.barker@sancloud.com>

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

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


  parent reply	other threads:[~2021-09-08 11:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 11:38 [PATCH v4 0/2] Refactor and improve full help output from tools Paul Barker
2021-09-08 11:38 ` [PATCH v4 1/2] tools: Refactor full help printing Paul Barker
2021-09-25  0:37   ` Tom Rini
2021-09-08 11:38 ` Paul Barker [this message]
2021-09-25  0:37   ` [PATCH v4 2/2] tools: Handle PAGER containing arguments Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210908113802.5252-3-paul.barker@sancloud.com \
    --to=paul.barker@sancloud.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox