git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/4] send-email: don't attempt to prompt if tty is closed

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 31, 2009, 16:22 UTC
Message-ID
<e439cc23328dc25d153baed21f6ad7d90106eb03.1238516122.git.jaysoffian@gmail.com>
In-Reply-To
<cover.1238516122.git.jaysoffian@gmail.com>

Attempting to prompt when the tty is closed (typically when running from cron) is pointless and emits a warning. This patch causes ask() to return early, squelching the warning.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
 git-send-email.perl |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 5916c86..d790660 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -612,6 +612,9 @@ sub ask {
 	my $default = $arg{default};
 	my $resp;
 	my $i = 0;
+	return defined $default ? $default : undef
+		unless defined $term->IN and defined fileno($term->IN) and
+		       defined $term->OUT and defined fileno($term->OUT);
 	while ($i++ < 10) {
 		$resp = $term->readline($prompt);
 		if (!defined $resp) { # EOF
-- 
1.6.2.1.427.g15408
Previous: Jay SoffianNext: Jay Soffian
Message 2 of 7 in “send-email: correct various issues”
  1. 0/4 send-email: correct various issuesJay Soffian, Mar 31, 2009
  2. 1/4 send-email: don't attempt to prompt if tty is closedJay Soffian, Mar 31, 2009
  3. 2/4 send-email: ask_default should apply to all emails, not just the firstJay Soffian, Mar 31, 2009
  4. 3/4 send-email: correct two tests which were going interactiveJay Soffian, Mar 31, 2009
  5. 4/4 send-email: ensure quoted addresses are rfc2047 encodedJay Soffian, Mar 31, 2009
  6. Jeff KingMar 31, 2009
  7. Matthieu MoyApr 1, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.