Re: [PATCH] send-email: validate & reconfirm interactive responses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stephen Boyd <bebarino@xxxxxxxxx> writes:

> On Tue, Aug 14, 2012 at 3:25 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> @@ -745,13 +752,15 @@ sub file_declares_8bit_cte {
>>  if (!defined $sender) {
>>         $sender = $repoauthor || $repocommitter || '';
>>         $sender = ask("Who should the emails appear to be from? [$sender] ",
>> -                     default => $sender);
>> +                     default => $sender,
>> +                     valid_re => qr/\@.*\./, confirm_only => 1);
>
> This is now bugging me if I just hit enter and don't want to specify
> anything for
> these headers (I want the defaults or what's in the files already).
> Can we allow
> the empty string to be valid as well so I don't have to go through
> these prompts?

That indeed was the intention, and if it is not behaving, you found
a bug.

The relevant code in "sub ask" does this:

		...
                $resp = $term->readline($prompt);
                if (!defined $resp) { # EOF
                        print "\n";
                        return defined $default ? $default : undef;
                }
                if ($resp eq '' and defined $default) {
                        return $default;
                }
                if (!defined $valid_re or $resp =~ /$valid_re/) {
                        return $resp;
                }

I am scratching my head wondering why your "just hit enter" does not
trigger the "if response is empty and we have default, just return it"
codepath we can see above.  It shouldn't even trigger the regexp
based validation codepath in the first place.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]