Linux maintainer tooling and workflows
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@rivosinc.com>
To: tools@linux.kernel.org
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Subject: [PATCH] pr: Add --nostdin, to disable TTY detection
Date: Wed, 12 Oct 2022 16:02:11 -0700	[thread overview]
Message-ID: <20221012230211.29402-1-palmer@rivosinc.com> (raw)

I'm running b4 from a bash script that does all sorts of wacky stuff to
try and talk to the Yubikey, which causes "b4 pr" to think I'm trying to
pass it message IDs from standard in when I'm actually trying to do some
via positional arguments.  This adds a --nostdin command-line argument
to turn off the automatic TTY-based detection and just force positional
arguments.

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
---
I added this to b4.5.rst, not sure if that was the right place to put
it.  I noticed some other arguments in the source that don't appear to
be documented in there.
---
 b4/command.py | 2 ++
 b4/pr.py      | 2 +-
 man/b4.5.rst  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/b4/command.py b/b4/command.py
index b16043e..7fcf73f 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -194,6 +194,8 @@ def cmd():
                              'the identity must match a [sendemail "identity"] config section'))
     sp_pr.add_argument('--dry-run', dest='dryrun', action='store_true', default=False,
                        help='Force a --dry-run on git-send-email invocation (use with -s)')
+    sp_pr.add_argument('--nostdin', dest='nostdin', action='store_true', default=False,
+                       help="Disable TTY detection for stdin.")
     sp_pr.add_argument('msgid', nargs='?',
                        help='Message ID to process, or pipe a raw message')
     sp_pr.set_defaults(func=cmd_pr)
diff --git a/b4/pr.py b/b4/pr.py
index 1c00e75..6c5da58 100644
--- a/b4/pr.py
+++ b/b4/pr.py
@@ -472,7 +472,7 @@ def main(cmdargs):
     gitdir = cmdargs.gitdir
     lmsg = None
 
-    if not sys.stdin.isatty():
+    if not sys.stdin.isatty() and not cmdargs.nostdin:
         logger.debug('Getting PR message from stdin')
         msg = email.message_from_bytes(sys.stdin.buffer.read())
         cmdargs.msgid = b4.LoreMessage.get_clean_msgid(msg)
diff --git a/man/b4.5.rst b/man/b4.5.rst
index 073f32a..4dd079d 100644
--- a/man/b4.5.rst
+++ b/man/b4.5.rst
@@ -253,6 +253,7 @@ optional arguments:
   -l, --retrieve-links  Attempt to retrieve any Link: URLs (use with -e)
   -f MAILFROM, --from-addr MAILFROM
                         Use this From: in exploded messages (use with -e)
+  --nostdin             Disable TTY detection for stdin.
 
 *Example*: b4 pr 202003292120.2BDCB41@keescook
 
-- 
2.38.0


             reply	other threads:[~2022-10-12 23:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 23:02 Palmer Dabbelt [this message]
2022-10-27 16:57 ` [PATCH] pr: Add --nostdin, to disable TTY detection Konstantin Ryabitsev

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=20221012230211.29402-1-palmer@rivosinc.com \
    --to=palmer@rivosinc.com \
    --cc=tools@linux.kernel.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).