Thread (19 messages) flat view 19 messages, 7 authors, 2016-06-15

Re: [PATCH 3/6] Remove return undef from ask()

From: Jay Soffian <hidden>
Date: 2016-06-15 22:46:42

On Sun, May 3, 2009 at 4:26 PM, Jeff King [off-list ref] wrote:
On a side note, while looking at this function, I wonder if that "return
undef" is correct after all. We get there only if the user has failed to
give valid input 10 times, so presumably it is a sanity check to
prevent runaway input errors
Correct, that is why it is there.
(and I am cc'ing Jay, who added the
function not too long ago). Should we be respecting the default here, as
we do when we get EOF?
The original motivation was a user who was running send-email from
cron and it was looping forever. That case is now actually handled
before the loop, and all other normal cases are handled inside the
loop.

So the only thing that can cause the loop to exit (AFAIK) is when
$valid_re is passed in and the user provides invalid input 10x.
Although I tend to think if the user is
repeatedly giving us bogus input that we should not just proceed, but
should probably die. Because otherwise we are guessing at what they
might have wanted.
Well, it returns undef, at which point it's up to the caller to figure
out what to do. You'll notice the one caller which passes in $valid_re
dies:

die "Send this email reply required" unless defined $_;

Letting the caller decide what to do provides more flexibility.

j.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help