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

Re: [PATCH 1/2] send-email: refactor and ensure prompting doesn't loop forever

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 29, 2009, 01:48 UTC
Message-ID
<76718490903281848l5102afc3x89eed40ed6083dcc@mail.gmail.com>
In-Reply-To
<1238290751-57461-1-git-send-email-jaysoffian@gmail.com>
On Sat, Mar 28, 2009 at 9:39 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> There are three callers of the function:
Where by "three" I mean "four". Please use this commit message instead:

---snip--- Several places in send-email prompt for input, and will do so forever when the input is EOF. This is poor behavior when send-email is run unattended (say from cron).

This patch refactors the prompting to an ask() function which takes a prompt, an optional default, and an optional regex to validate the input. The function returns on EOF, or if a default is provided and the user simply types return, or if the input passes the validating regex (which accepts all input by default). The ask() function gives up after 10 tries in case of invalid input.

There are four callers of the function:
1) "Who should the emails appear to be from?" which provides a default
sender. Previously the user would have to type ctrl-d to accept the
default. Now the user can just hit return, or type ctrl-d.
2) "Who should the emails be sent to?". Previously this prompt passed a
second argument ("") to $term->readline() which was ignored. I believe
the intent was to allow the user to just hit return. Now the user
can do so, or type ctrl-d.
3) "Message-ID to be used as In-Reply-To for the first email?".
Previously this prompt passed a second argument (effectively undef) to
$term->readline() which was ignored. I believe the intent was the same
as for (2), to allow the user to just hit return. Now the user can do
so, or type ctrl-d.
4) "Send this email?". Previously this prompt would loop forever until
it got a valid reply. Now it stops prompting on EOF or a valid reply. In
the case where confirm = "inform", it now defaults to "y" on EOF or the
user hitting return, otherwise an invalid reply causes send-email to
terminate.
A followup patch adds tests for the new functionality.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---snip---
Thanks,
j.
Previous: Jay SoffianNext: Junio C Hamano
Message 8 of 17 in “send-email: refactor and ensure prompting doesn't loop forever”
  1. 1/2 send-email: refactor and ensure prompting doesn't loop foreverJay Soffian, Mar 29, 2009
  2. 2/2 send-email: add tests for refactored promptingJay Soffian, Mar 29, 2009
  3. Björn SteinbrinkMar 31, 2009
  4. Jay SoffianMar 31, 2009
  5. Jay SoffianMar 31, 2009
  6. Björn SteinbrinkMar 31, 2009
  7. Jay SoffianMar 31, 2009
  8. Jay SoffianMar 29, 2009
  9. Junio C HamanoMar 30, 2009
  10. Matthieu MoyMar 30, 2009
  11. Jay SoffianMar 30, 2009
  12. Jay SoffianMar 30, 2009
  13. Matthieu MoyMar 30, 2009
  14. Jay SoffianMar 30, 2009
  15. Jay SoffianMar 30, 2009
  16. Matthieu MoyMar 31, 2009
  17. Jay SoffianMar 31, 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.